7.3. Create a New Project from Blank Project¶
Caution
This version is already obsolete. Please check the latest guideline.
Table of contents
This chapter describes a method to create a new project from a blank project.
7.3.1. Prerequisites¶
This chapter presumes that the following conditions are in place. If these prerequisites are not fulfilled, first set up the same.
- Spring Tool Suite should be operational.
- Maven should be executable in command line.
- Internet connectivity.
Note
If it is required to connect to the internet through proxy server, STS proxy settings and Maven proxy settings are required.
7.3.2. Verification Environment¶
In this chapter, operations are validated in versions given below.
Type | Name |
---|---|
OS | Windows 7 |
JVM | Java 1.8 |
IDE | Spring Tool Suite 3.6.4.RELEASE (hereafter called as “STS”) |
Build Tool | Apache Maven 3.3.9 (hereafter called as “Maven”) |
Application Server | Pivotal tc Server Developer Edition v3.1 (enclosed in STS) |
7.3.3. Types of Blank Project¶
Following two types of blank projects are provided depending on usage.
Type | Usage |
---|---|
This should be used when developing a real application that is to be released in commercial environment. Following types of project templates are provided as Archetype of Maven.
This guideline recommends using a project having multi-project structure. |
|
This should be used when creating simple applications such as POC (Proof Of Concept), prototype, sample, etc. Following types of project templates are provided as Archetype of Maven. (Projects for Eclipse WTP are also provided; however, their description is omitted in this chapter)
This guideline follows a procedure wherein various tutorials are performed using a single project. |
7.3.4. Create a project of multi-project structure¶
For method of creating a project of multi-project structure, refer to: “Create Web application development project”.
The above document includes
- Method to create a project of multi-project structure
- Method to create a war file
- Description of customized locations from blank project
- Description of project structure
7.3.5. Create a project of single-project structure¶
This section describes about how to create a project of single-project structure.
First, go to the folder wherein a project is to be created.
cd C:\work
Create a project using archetype:generate of Maven Archetype Plugin.
mvn archetype:generate -B^
-DarchetypeCatalog=http://repo.terasoluna.org/nexus/content/repositories/terasoluna-gfw-releases^
-DarchetypeGroupId=org.terasoluna.gfw.blank^
-DarchetypeArtifactId=terasoluna-gfw-web-blank-mybatis3-archetype^
-DarchetypeVersion=5.1.0.RELEASE^
-DgroupId=todo^
-DartifactId=todo^
-Dversion=1.0.0-SNAPSHOT
Parameter | Description |
---|---|
-B | batch mode (interaction omitted)
|
-DarchetypeCatalog
|
Specify repository of TERASOLUNA Server Framework for Java (5.x). (fixed) |
-DarchetypeGroupId
|
Specify groupId of blank project. (fixed) |
-DarchetypeArtifactId
|
Specify archetypeId (ID to identify template) of blank project. (customization is necessary) Specify any of archetypeId given below.
In above example, |
-DarchetypeVersion
|
Specify the version of blank project. (fixed) |
-DgroupId
|
Specify the groupId of project to be created. (customization is necessary) In above example, |
-DartifactId
|
Specify the artifactId of project to be created. (customization is necessary) In above example, |
-Dversion
|
Specify the version of project to be created. (customization is necessary) In above example, |
Warning
In pom.xml
of blank project, dependency on in-memory database (H2 database) is specified.
This setting is used to perform minor validations (prototype creation or POC (Proof Of Concept)). It is not assumed to be used in actual development.
<dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency>
When H2 Database is not to be used, this setting should be deleted.
7.3.6. Import a project in IDE (STS)¶
This section describes about how to import a created project in STS.
Note
Here, an example to import a single project is given; however, multi projects can also be imported using the same procedure.
From STS menu, select [File] -> [Import] -> [Maven] -> [Existing Maven Projects] -> [Next] to open a dialog for selecting the project created using archetype.
Set C:\work\todo
in Root Directory, and click [Finish] while pom.xml of todo is selected in Projects.
When import is successful, a project shown below is displayed in Package Explorer.
Note
If build error occurs after import, right click the project name and click “Maven” -> “Update Project…”. Then by clicking “OK”, the error may get resolved.
Tip
Display format of package is “Flat” by default; however, view is better if set to “Hierarchical”.
Click “View Menu” of Package Explorer (down arrow on the extreme right), and select “Package Presentation” -> “Hierarchical”.
When Package Presentation is set to Hierarchical, the display would be as follows:
7.3.7. Deploy and start application server (ts Server)¶
The section describes about how to deploy and launch a project on application server on STS.
Note
In case of multi projects, projects (archetypeId-web) storing the components of application layer (Web layer) will be deployment targets.
Right click the imported project and select “Run As” -> “Run on Server”.
Select AP server (Pivotal tc Server Developer Edition v3.0), and click “Next”.
Check whether the selected project is included in “Configured” and click “Finish” to start the server.
Note
The error that occurs at the time of starting the application server may get resolved if clean operations given below are performed.
- Clean projectFrom STS menu, select [Project] -> [Clean…], select the target on Clean dialog and click “OK”.
- Update Project of Maven
- Clean deployed resourceRight click “tc Server” of “Servers” view -> [Clean…]
- Clean work directory of application server (tc Server)Right click the “tc Server” of “Servers” view -> [Clean tc Server Work Directory…]
If http://localhost:8080/todo is accessed in browser, screen shown below is displayed.