2014-11-03 94 views
0


我使用Velocity在Java項目中生成源代碼。我將項目導出爲jar文件以在其他項目中使用它。
這是我的速度屬性文件內容:
runtime.log.logsystem.class = org.apache.velocity.runtime.log.SystemLogChute
resource.loader =資源/
classpath.resource.loader.class = org.apache .velocity.runtime.resource.loader.ClasspathResourceLoader

我收到此錯誤:
內部編譯器錯誤:java.lang.NoClassDefFoundError:org/apache/velocity/exception/ResourceNotFoundException java.lang.Class.getDeclaredConstructors0(Native Method)Velocity中的「NoClassDefFoundError」

回答

0

該類在構建期間存在,但它取決於環境,如果您在J2EE環境中工作比您可以獲得NoClassD efFoundError即使存在類,因爲它可能對相應的類加載器不可見。

將所有依賴關係置於WEB-INF/lib並將它們添加到CLASSPATH

Where to Put the Velocity Jar

First of all you have to decide whether you will use the dependency-free version 
of velocity.jar or the version including all dependend jars. If you are not worried 
about collisions with Avalon Logkit, Commons Collections or Jakarta Oro, using the jar 
containing all dependencies is very convenient. 

Putting the velocity jar in WEB-INF/lib your web application 
will result in it's classes being available in the classpath for that web application.