找不到org/apache/log4j/Priority

出错日志

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Priority

原因

log4j的2.x版本是没有org/apache/log4j/Priority的。Mybatis有一个配置(logImpl)是log文件相关的,项目中用的是log4j2.x,但配置却配置为了log4j(也就是1.x),所有出现了问题。

Invalid bound statement

出错日志

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

出错原因

        目录(src/main/java)在IDEA中目录是普通属性,所以只有.java文件会默认编译,.xml文件不会被编译。可发现在Idea生成的classes中没有.xml文件。

        MyEclipse中可以运行是因为MyEclipse中建立的是目录(src/main/java)的属性是资源目录,所以MyEclipse识别了这个属性会自动把这个目录的所有内容编译生成在classes中。

解决方法

pom.xml中配置一下节点

<project>
......
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>