Initial Setup of RESTful Web Service Project for Container¶
The following is procedures of initial setup of the RESTful web service project for container:
- Generating RESTful web service project for container
- Confirm communications of RESTful web service project
- Create a container image
- Run Container Image
Preliminary preparations¶
Install one of the following for use with Communication confirmation.
- Firefox
- Chrome
Overview of the generated project¶
The overview of the project generated by this procedure is as follows.
Item | Description |
---|---|
Project Type | Maven project |
Project composition | Single project composition |
DB used | H2 Database Engine (embedded in the application) |
Built-in adapter |
|
What is included in the generated project? | The following is included in the generated project:
|
For relationship with other projects and directories, see Maven Archetype Configuration.
Create blank project¶
Generate a blank project using the archetypes provided by Nablarch.
Execute the mvn command¶
Use Maven Archetype Plugin(external site) to generate a blank project.
Change the current directory to the directory where the blank project (can be any directory) is to be created.
Execute the following command.
mvn archetype:generate -DarchetypeGroupId=com.nablarch.archetype -DarchetypeArtifactId=nablarch-container-jaxrs-archetype -DarchetypeVersion=6u2
The version of Nablarch used in the above command is 6u2. If you want to change the version, change the following parameters.
Set value | Description |
---|---|
archetypeVersion | Specify the version of the archetype you wish to use. (Nablarch 6u2 or later must be specified) |
Enter project information¶
When the above command is executed, you will be asked to enter the following information about the blank project to be generated.
Input item | Description | Configuration example |
---|---|---|
groupId | Group ID (normally, enter the package name) | com.example |
artifactId | Artifact ID | myapp-container-jaxrs |
version | Version number | 0.1.0 |
package | Package (normally the same as group ID) | com.example |
Important
Item groupId and package are mapped to the Java package name. Use lowercase letters, numbers, and dots for these input values, and do not use hyphens.
When you have finished entering project information, Y: : will appear.
- Enter 「Y」 if you want to generate a template based on the information you have entered.
- Enter 「N」 if you wish to redo the project information entry.
If the command ends normally, a blank project is created under the current directory.
Communication confirmation¶
The communication confirmation mechanism and procedures are the same as for a normal RESTful web service project. Thus, see Initial Setup of RESTful Web Service Project.
Note
Artifact ID should be replace with myapp-container-jaxrs
to specify the directory or command.
Create a container image¶
The way to create a container image is the same as in a web project for containers, so see Initial Setup of Web Project for Container.
Note
Artifact ID should be replace with myapp-container-jaxrs
to specify the directory or command.
Run a container image¶
The way to run the container image is the same as in a web project for containers, so see Initial Setup of Web Project for Container.
Note
Artifact ID should be replace with myapp-container-jaxrs
to specify the directory or command.
Note
The operation can be checked at the following URL.
http://localhost:8080/find/json
http://localhost:8080/find/xml
Configure the database¶
The blank project is initially configured to use the H2 Database Engine. To change the RDBMS to be used, refer to Procedure for Changing the RDBMS used for the configuration.
In addition, to generate and execute DDL from ER diagrams and automatically generate entity classes, you need to initialize and run gsp-dba-maven-plugin. For details, see Initial Configuration Method of gsp-dba-maven-plugin (DBA Work Support Tool).
Supplementary notes¶
For information on the method of confirming the data of H2 and tools included in the blank project, see Initial Setup Procedure Supplementary Information.