现在JDK1.5已经越来越普及了,使用它编写或者改写的程序也越来越多,当我们把符合JDK1.5新语法特征的程序送给maven编译时会出现下列问题.

这时该如何使用 -source 1.5 以启用泛型呢,将pom.xml文件添加一段即可.请看完整的pom.xml:
<
project
xmlns
="http://maven.apache.org/POM/4.0.0"

xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation
="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<
modelVersion
>
4.0.0
</
modelVersion
>
<
groupId
>
com.junglesong
</
groupId
>
<
artifactId
>
sqlanywhere
</
artifactId
>
<
packaging
>
jar
</
packaging
>
<
version
>
1.0.3
</
version
>
<
name
>
sqlanywhere
</
name
>
<
url
>
http://maven.apache.org
</
url
>
<
dependencies
>
<
dependency
>
<
groupId
>
junit
</
groupId
>
<
artifactId
>
junit
</
artifactId
>
<
version
>
3.8.1
</
version
>
<
scope
>
test
</
scope
>
</
dependency
>
<
dependency
>
<
groupId
>
dom4j
</
groupId
>
<
artifactId
>
dom4j
</
artifactId
>
<
version
>
1.6.1
</
version
>
<
scope
>
compile
</
scope
>
</
dependency
>
<
dependency
>
<
groupId
>
log4j
</
groupId
>
<
artifactId
>
log4j
</
artifactId
>
<
version
>
1.2.14
</
version
>
<
scope
>
compile
</
scope
>
</
dependency
>
</
dependencies
>

<
build
>
<
finalName
>
sqlanywhere1.0.3
</
finalName
>
<
plugins
>
<
plugin
>
<
artifactId
>
maven-compiler-plugin
</
artifactId
>
<
configuration
>
<
source
>
1.5
</
source
>
<
target
>
1.5
</
target
>
</
configuration
>
</
plugin
>
</
plugins
>
</
build
>
</
project
>
上面<build>节点中的<plugin>部分就是我们要添加的,就这么简单.
<
plugin
>
<
artifactId
>
maven-compiler-plugin
</
artifactId
>
<
configuration
>
<
source
>
1.5
</
source
>
<
target
>
1.5
</
target
>
</
configuration
>
</
plugin
>
此后mvn将使用jDK1.5编译程序.
本文介绍如何在Maven项目中配置JDK1.5进行编译,通过在pom.xml文件中添加maven-compiler-plugin插件并设置<source>1.5和<target>1.5来启用泛型等特性。
523

被折叠的 条评论
为什么被折叠?



