zoukankan      html  css  js  c++  java
  • 如何修改maven的默认jdk版本

    转自:https://www.cnblogs.com/Hxinguan/p/6132446.html

    问题:

    1、创建maven项目的时候,jdk版本是1.5版本,而自己安装的是1.7或者1.8版本。

    2、每次右键项目名-maven->update project 时候,项目jdk版本变了,变回1.5版本或者其他版本

    解决办法:

    解决办法一:在项目中的pom.xml指定jdk版本,如下:

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

    这个方法只能保证该项目是jdk1.8版本,每次新建项目都得加上面代码,不推荐使用,推荐第二种方法。

    解决方法二:在maven的安装目录找到settings.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进行设置。window->preferences->maven->user settings,user settings那里选择maven安装目录下的settings.xml文件。

  • 相关阅读:
    Python Ethical Hacking
    Python Ethical Hacking
    Python Ethical Hacking
    AcWing 1049. 大盗阿福 状态机模型dp
    AcWing 11. 背包问题求方案数
    AcWing 10. 有依赖的背包问题
    AcWing 7. 混合背包问题
    AcWing 532. 货币系统
    2018-2019 ACM-ICPC, Asia East Continent Final L Eventual … Journey
    AcWing 487. 金明的预算方案
  • 原文地址:https://www.cnblogs.com/moonsoft/p/10358599.html
Copyright © 2011-2022 走看看