Eclipse创建简单的java maven项目

Eclipse创建简单的java maven项目,非web项目

1、

2、

3、

4、更改Maven项目中使用的jre

更改成功,此项目的jre变成我们自己jdk中的jre!

方式二:永久更改

在自己电脑中找到.m2下的·settings.xml(C:\Users\自己的\.m2),添加

    <profiles>
        <profile>
            <id>jdk-1.8</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.8</jdk>
            </activation>
            <properties>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>
    </profiles>

settings.xml配置文件修改完之后,我们可以更新Maven项目来改变jre。

这时,我们发现项目中的jre已经变成1.8了,以后我们再使用Eclipse创建Maven项目时默认的jre版本都会是1.8

5、pom.xml文件中添加junit

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

6、简单测试

    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
    }
    
    @Test
    public void test(){
        System.out.println("测试");
    }

猜你喜欢

转载自blog.csdn.net/sky198989/article/details/81198312