我在Java项目中使用Velocity来生成源代码。我将项目导出为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.CoC.DeClaredConstructors0(本机方法)中的java.lang.NoClassDefFoundError:org / apache / velocity / exception / ResourceNotFoundException
答案 0 :(得分:0)
该类在构建期间存在,但它依赖于环境,如果您在J2EE环境中工作,即使存在类,也可以获得NoClassDefFoundError,因为它可能对相应的类加载器不可见。
将所有依赖项置于WEB-INF/lib
并将其添加到CLASSPATH
。
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.