美文网首页我爱编程
Jenkins 编译 xml文件丢失

Jenkins 编译 xml文件丢失

作者: 朝圣的路上 | 来源:发表于2016-11-21 14:25 被阅读189次

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

    相关文章

      网友评论

        本文标题:Jenkins 编译 xml文件丢失

        本文链接:https://www.haomeiwen.com/subject/pwjupttx.html