Maven:maven默认jdk版本是1.5,现在一般使用1.8,如何修改默认版本?

方法一:在项目中的pom.xml文件中修改

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

这种方法只能保证该项目jdk为1.8,每次新建都得添加上面代码,不推荐使用。

方法二:在maven安装目录conf文件夹中的setting.xml中修改

<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>

在eclipse的maven插件中必须修改引入的setting.xml位置才能生效

 

猜你喜欢

转载自www.cnblogs.com/ysq2018China/p/10349472.html