2014-11-03 124 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.