错误 java.lang.NoClassDefFoundError: org/apache/velocity/context/Context
使用mybatis-plus自动生成文件的时候,报下面的错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/velocity/context/Context
at com.baomidou.mybatisplus.generator.AutoGenerator.execute(AutoGenerator.java:100)
at com.layuicms.erp.utils.CodeGenerator.main(CodeGenerator.java:101)
Caused by: java.lang.ClassNotFoundException: org.apache.velocity.context.Context
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
Process finished with exit code 1
原因是缺少了依赖
解决方案
pom.xml文件当中加入velocity的依赖
<!-- 模板引擎 -->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.0</version>
</dependency>