如何根据一些参数,自动生成一个简单的maven工程,然后导入Eclipse直接使用?(maven命令)

1. 使用mvn archetype:generate命令

2. 选择archetype类型:(默认是org.apache.maven.archetypes:maven-archetype-quickstart

3. 选择版本(6->1.1):(默认6)

4. 输入groupId :com.nmj.test

5. 输入artifactId :test

6. 输入version :(默认1.0-SNAPSHOT)

7. 输入package :(默认)

Final:

maven默认使用JDK是1.5。修改pom.xml,追加:

  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

Or

  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

Links:

1. Project creation

2. Setting the -source and -target of the Java Compiler

原文地址:https://www.cnblogs.com/niaomingjian/p/8600980.html