我的Maven2之旅:十二.使用JDK1.5编译Maven工程

本文介绍如何在Maven项目中配置JDK1.5进行编译,通过在pom.xml文件中添加maven-compiler-plugin插件并设置<source>1.5和<target>1.5来启用泛型等特性。

 现在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编译程序.

注:转自http://www.blogjava.net/sitinspring

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值