maven之jdk升级配置和jar包升级配置

一 jar包升级配置

如下面的代码所示,在properties标签中,加入<spring.version>配置,下面<dependency>中的<version>版本配置使用${spring.version}。例如:我们要升级项目中spring版本,我们直接改spring.version标签中的版本号即可。

<properties>

   <!-- jar包统一升级管理 -->

   <spring.version>3.2.2.RELEASE</spring.version>

 </properties>

 <dependencies>

   <dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-core</artifactId>

        <version>${spring.version}</version>

    </dependency>

    <dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-beans</artifactId>

        <version>${spring.version}</version>

   </dependency>

   <dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-context</artifactId>

        <version>${spring.version}</version>

    </dependency>

    <dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-aop</artifactId>

        <version>${spring.version}</version>

    </dependency>

    <dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-expression</artifactId>

        <version>${spring.version}</version>

    </dependency>

    <dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-web</artifactId>

        <version>${spring.version}</version>

    </dependency>

    <dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-webmvc</artifactId>

        <version>${spring.version}</version>

    </dependency>

    <dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-tx</artifactId>

        <version>${spring.version}</version>

    </dependency>

    <dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-jdbc</artifactId>

        <version>${spring.version}</version>

    </dependency>

    <!-- spring end-->

   </dependencies>

 

二  maven jdk升级配置

maven 默认使用的 jdk 版本一般较低。

新建一个 maven 项目,如下


项目左下方出现一个感叹号,JRE 显示的是 1.5 版本。解决方式有两种,一种是配置 pom.xml,一种是配置 settings.xml

方式一:settings.xml 配置

打开 %maven%/conf/settings.xml 文件并编辑它(%maven% 表示 maven 的根目录) 

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

找到 <profiles> 节点,并添加如上配置(本机 jdk 1.7.0_79 版本,配置时修改成你本机的 jdk 版本)。保存并关闭。重启 eclipse 即可。
重启后配置生效。

方式二:pom.xml 配置

<build> 节点添加如下配置(本机 jdk 1.7.0_79 版本,配置时修改成你本机的 jdk 版本):

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

配置完成后,需要执行一次更新项目配置的动作。选中项目 --> 右键 --> Maven --> Update Projecteclipse luna 版本,helios
indigo
版本选择 Update Project Configuration)。
pom.xml
仅作用于当前项目(每个项目都需要配一次),而 settings.xml 的配置是全局的(仅需要配一次)。以上两种配置方式中选其一即可。

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

御前两把刀刀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值