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标签下添加如下代码。

<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目录下。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容