Please refer to here for environment construction.
I couldn't find a way to create a Java 11 project directly, so I'll create a Java 8 project first. After creating, change to Java 11 settings.
OS:Windows 10 Pro 64bit Editor:Visual Studio Code 1.42.1 JDK:AdoptOpenJDK 11.0.6+10 x64 Apache Maven:v3.6.3
I think that you can also enter the command of Visual Studio Code, but this time I will create it by entering the command at the command prompt. Open a command prompt and move to the folder where you want to create the template. This time, create it in "D: \ JAVA \ Project".
mvn archetype:generate -DinteractiveMode=false -DarchetypeGroupId=pl.org.miki -DarchetypeArtifactId=java8-quickstart-archetype -DgroupId=com.example -DartifactId=hello -Dversion=1.0-SNAPSHOT -Dpackage=com.example -Dpackaging=jar
Line breaks for readability.
mvn archetype:generate
-DinteractiveMode=false
-DarchetypeGroupId=pl.org.miki
-DarchetypeArtifactId=java8-quickstart-archetype
-DgroupId=com.example
-DartifactId=hello
-Dversion=1.0-SNAPSHOT
-Dpackage=com.example
-Dpackaging=jar
The places to be specified arbitrarily are as follows. -DgroupId It will be the group ID. It is for identifying the creator, company, organization, etc.
-DartifactId It will be the artifact ID. I think it can be called the project name.
-Dversion You can specify the version. Unless you are particular about it, I think "1.0-SNAPSHOT" is fine.
-Dpackage The basics are the same as "-DgroupId".
D:\JAVA\Project>mvn archetype:generate -DinteractiveMode=false -DarchetypeGroupId=pl.org.miki -DarchetypeArtifactId=java8-quickstart-archetype -DgroupId=com.example -DartifactId=hello -Dversion=1.0-SNAPSHOT -Dpackage=com.example -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.1.2:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.1.2:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.1.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[INFO] Archetype [pl.org.miki:java8-quickstart-archetype:1.0.0] found in catalog remote
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: java8-quickstart-archetype:1.0.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.example
[INFO] Parameter: artifactId, Value: hello
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.example
[INFO] Parameter: packageInPathFormat, Value: com/example
[INFO] Parameter: compilerMode, Value: simple
[INFO] Parameter: package, Value: com.example
[INFO] Parameter: groupId, Value: com.example
[INFO] Parameter: testLibrary, Value: junit
[INFO] Parameter: artifactId, Value: hello
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Project created from Archetype in dir: D:\JAVA\Project\hello
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.255 s
[INFO] Finished at: 2020-03-08T15:28:02+09:00
[INFO] ------------------------------------------------------------------------
It is created with such a folder structure.
D:.
└─src
├─main
│ └─java
│ └─com
│ └─example
└─test
└─java
└─com
└─example
Change java.version to 11.
Change before
<java.version>1.7</java.version>
After change
<java.version>11</java.version>
I like war for packaging, so change it to war.
Change before
<packaging>jar</packaging>
After change
<packaging>war</packaging>
This is the modified pom.xml.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>hello</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
This completes the template creation.
Create a Java 8 project with Maven https://qiita.com/mkamotsu/items/98c6d721a87a74f2b36f