2014-09-24 64 views
0

我有一個在Netbeans中啓動的Tomcat 8 web項目。 在Netbeans中,我設置了一些全局庫,然後添加到項目中。在Netbeans中構建項目完美地工作。即使jar在WEB-INF/lib中也沒有找到軟件包

問題是,當我嘗試在使用Ant的Unix平臺上構建時。 我用的Netbeans自動生成的build.xml文件,唯一的區別是,我現在必須指定這些「全局」庫,我這樣做,因爲這樣:

ant -Dlibs.spring-framework-4.0.6.classpath="../libs/spring-framework-4.0.6.RELEASE" clean dist 

然而這會導致這些類型錯誤:

error: package org.springframework.beans.factory does not exist 

如果我去看看在網絡/ WEB-INF/lib目錄中生成文件夾內,罐子是存在的,如果我看上去裏面我找到org.springframework.beans.factory類。

如果我運行在調試模式下的螞蟻它明確規定,被複制在庫:

[copy] Copying /libs/spring-framework-4.0.6.RELEASE/spring-beans-4.0.6.RELEASE.jar to /App/build/web/WEB-INF/lib/spring-beans-4.0.6.RELEASE.jar 

據我瞭解,在WEB-INF/lib目錄默認是打開的類路徑。這是不是發生了什麼,我需要專門告訴它將此目錄添加到類路徑?

回答

0

我自己找到了解決方案,結果證明我必須專門引用每個jar文件,但僅僅引用該目錄是不夠的。

所以這個:

ant -Dlibs.spring-framework-4.0.6.classpath="../libs/spring-framework-4.0.6.RELEASE" clean dist 

本來應該是這樣的:

ant -Dlibs.spring-framework-4.0.6.classpath="../libs/spring-framework-4.0.6.RELEASE/spring-aop-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-aspects-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-beans-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-context-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-context-support-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-core-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-expression-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-framework-bom-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-instrument-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-instrument-tomcat-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-jdbc-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-jms-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-messaging-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-orm-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-oxm-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-test-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-tx-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-web-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-webmvc-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-webmvc-portlet-4.0.6.RELEASE.jar:../libs/spring-framework-4.0.6.RELEASE/spring-websocket-4.0.6.RELEASE.jar" clean dist 
相關問題