11.8. Maven builds Java project

发布时间 :2025-10-25 12:23:15 UTC      

Maven usage prototype archetype The plug-in creates the project. To create a simple Java application, we will use the maven-archetype-quickstart Plug-in.

In the following example, we will create a maven-based java application project under the C:MVN folder.

The format of the command is as follows:

mvn archetype:generate "-DgroupId=com.companyname.bank" "-DartifactId=consumerBanking" "-DarchetypeArtifactId=maven-archetype-quickstart" "-DinteractiveMode=false"

Parameter description:

  • -DgroupId The name of the organization, the reverse of the company’s website and the name of the project

  • -DartifactId : project name-module name

  • -DarchetypeArtifactId Specify ArchetypeId,maven-archetype-quickstart to create a simple Java application

  • -DinteractiveMode Whether to use interactive mode or not

The resulting folder structure is as follows:

image0

Description of each folder:

Folder structure

Description

ConsumerBanking

Contains the src folder and pom.xml

Src/main/java contains

The java code file is under the package structure (com/companyName/bank).

Src/main/java test

The test code file is under the package structure (com/companyName/bank).

Src/main/resources

Contains the image / properties file (in the above example, we need to create this structure manually).

C:MVNconsumerBankingsrcmainjavacomcompanynamebank 文件夹中,可以看到一个 App.java,代码如下:

11.8.1. App.java

packagecom.companyname.bank;/\*\* \* Hello world!
\*\*/publicclassApp{publicstaticvoidmain(String[]args){System.out.println("Hello
World!");}}

打开 C:MVNconsumerBankingsrctestjavacomcompanynamebank 文件夹,可以看到 Java 测试文件 AppTest.java。

11.8.2. AppTest.java

packagecom.companyname.bank;importjunit.framework.Test;importjunit.framework.TestCase;importjunit.framework.TestSuite;/\*\*
\* Unit test for simple App.\*/publicclassAppTestextendsTestCase{/\*\*
\* Create the test case \* \*@paramtestName name of the test
case\*/publicAppTest(StringtestName){super(testName);}/\*\* \*@returnthe
suite of tests being
tested\*/publicstaticTestsuite(){returnnewTestSuite(AppTest.class);}/\*\*
\* Rigourous Test :-)\*/publicvoidtestApp(){assertTrue(true);}}

For the rest of the development process, we just need to put it according to the structure mentioned in the table above, and Maven will help us take care of other things.

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.