mybatis提供的工具generator,能夠去官網下載html
一、將webapp改成3.0的版本java
原文件:mysql
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>web
改成:spring
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>Archetype Created Web Application</display-name>
</web-app>sql
並修改org.eclipse.wst.common.project.facet.core.xmlexpress
<installed facet="jst.web" version="2.3"/> 改成 <installed facet="jst.web" version="3.0"/>apache
二、spring-core包中不包括spring-context,設置pom.xml的時候須要都引入,不然會找不到context下相應的類json
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>mybatis
剛開始只引入了spring-core包,maven沒有自動下載spring-beans,spring-aop,spring-experssion包,引入context後會自動下載其餘三個jar包。
三、導入了mybatis-spring包後依然報java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean錯誤
緣由:maven配置中,能夠換個版本的mybatis-spring包
四、java.lang.NoClassDefFoundError: org/springframework/dao/support/DaoSupport 錯誤
緣由:缺乏spring-tx包
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
五、java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy;
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
六、org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.zd.dao.UserMapper.selectByPrimaryKey
一篇怪異的帖子回答:http://www.360doc.com/content/14/0424/09/15113968_371624182.shtml
最後一種回答解決了問題。。。。(我表示很詫異)
七、maven項目報錯,可是看不到報錯文件
打開窗口Markers,在工具欄處Window->Show View->Markers
能夠看到如下錯誤信息:
Description Resource Path Location Type One or more constraints have not been satisfied. ReBanana line 1 Maven Java EE Configuration Problem
解決辦法:在pom.xml配置文件中加入以下語句:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
以後再右鍵->Maven->Update Project,紅叉消失。
八、沒有SpringJUnit4ClassRunner類
沒有引入spring-test包
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
九、RequestMapping cannot be resolved to a type
缺乏spring-webmvc包
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
十、Cannot find class [org.springframework.http.converter.json.MappingJacksonHttpMessageConverter]
緣由:類名寫錯了,新版本類名爲MappingJackson2HttpMessageConverter
十一、Cannot resolve com.mysq.jdbc.Connection.ping method. Will use 'SELECT 1' instead. java.lang.NullPointerException
緣由:mysql-connector-java版本問題,原來版本爲6.0.3改成5.1.39後,沒有異常了
十二、Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userService' is defined
緣由:在web.xml必定要加上啓動spring的監聽器,這樣配置在xml文件中的bean纔會初始化
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
1三、CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.5.1 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-compiler-plugin:jar:3.5.1
maven-compiler-plugin版本過高,jar包沒下載下來,換個低版本的3.0
以下:
1四、Servlet /ReBanana threw load() exception
java.lang.ClassNotFoundException: com.fasterxml.jackson.core.JsonProcessingException
maven配置文件添加一下配置:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.1</version>
</dependency>
1五、打包文件發給他人時,需在當前目錄cmd中執行mvn clean命令,刪除maven項目產生的target文件。若maven正確安裝完成(可經過maven -version查看版本信息),顯示mvn不是內部命令。
在設置環境變量path的時候,可能覆蓋了原先設置着的變量,只要在path後面將
;%maven_home%\bin ----> ;%SystemRoot%\system32;%maven_home%\bin
1六、在上一問題後,若是再次運行run as--->maven install則會build failure
出現一下相似錯誤 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'roleService': Unsatisfied dependency expressed through method 'setRoleMapper' parameter 0: Error creating bean with name 'roleMapper' defined in file
先run as--->maven install,下載相應jar包,而後點擊工具類的project---->clean----->clean project selected below----->選擇本身項目後OK,再次run as--->maven install則不會出現該錯誤。(前提是你以前測試的時候是徹底正確的)
若是遇到其餘的問題以後再補充。
如有錯誤,望糾正。