在用jenkins編譯項目,然后發(fā)布到tomcat的過程中可能會出現(xiàn)類似這樣的錯誤
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'PMInvestEventDetailMapper' defined in file [/home/rdd/workdir/web/tomcat8_2/webapps/ROOT/WEB-INF/classes/com/cv/peseer/dao/PMInvestEventDetailMapper.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.core.io.Resource[]' for property 'mapperLocations'; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:com/cv/peseer/mapping/*.xml]: class path resource [com/cv/peseer/mapping/] cannot be resolved to URL because it does not exist
意思是找不到相應(yīng)的mapping文件呆细,這個在本地的eclipse里面是基本不會出現(xiàn)的。原因就在于凛驮,使用jenkins編譯的時候沒有把相應(yīng)的 xml 打包到war包里结榄。解決的辦法就是在項目的pom.xml文件里的build標(biāo)簽下添加如下代碼。
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
這個就是把java和source目錄下的配置文件拷貝到war包的classes目錄下舔痕。