java版本和maven的jdk不同,Maven项目依赖于JDK版本

I have projects that need to be build with a specific version of the JDK.

The problem isn't in the source and target parameters but in the jars of the runtime used during compilation.

In some cases I get a compilation error if I try to compile with the wrong JDK, but sometimes the build is successful and I get runtime errors when using the jars.

For example in eclipse I have the ability to establish the execution enviroment for the project in the .classpath file.

Is there a way to handle such situation in maven?

What I would like to have is the ability to handle JRE dependency like other dependencies of the project in the POM file.

UPDATE:

The accepted solution was the best one when I asked this question, so I won't change it. Meanwhile a new solution to this kind of problems has been introduced: Maven Toolchain. Follow the link for further details.

解决方案

I've found this article:

[...]

[...]

org.apache.maven.plugins

maven-compiler-plugin

2.1

true

true

${JAVA_1_4_HOME}/bin/javac

1.3

[...]

[...]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值