Jenkins 编译 xml文件丢失


在用jenkins编译项目,然后发布到tomcat的过程中可能会出现类似这样的错误

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

意思是找不到相应的mapping文件,这个在本地的eclipse里面是基本不会出现的。原因就在于,使用jenkins编译的时候没有把相应的 xml 打包到war包里。解决的办法就是在项目的pom.xml文件里的build标签下添加如下代码。


            
                src/main/java
                
                    **/*.properties
                    **/*.xml
                
                false
            
            
                src/main/resources
                
                    **/*.properties
                    **/*.xml
                
                false
            

这个就是把java和source目录下的配置文件拷贝到war包的classes目录下。

你可能感兴趣的:(Jenkins 编译 xml文件丢失)