maven+mybatis+spring xml文件没有编译到输出路径

发布时间:2020-05-22 05:44:29 作者:AchengCug
来源:网络 阅读:3017

maven+mybatis+spring在开发的时候,遇到如下错误:


org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘xxxService’: Unsatisfied dependency expressed through field ‘xxxMapper’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘xxxMapper’ defined in file [xxxMapper.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 [xxx-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/xxx/xxx/mapping/*.xml]: class path resource [com/xxx/xxx/mapping/] cannot be resolved to URL because it does not exist


经过检查发现maven编译后并没有将xml文件打包到输出路径,导致bean创建失败。

因此解决方法就是在pom文件中添加如下代码:

<build>
    ...
    <resources>
        <!--编译之后包含xml-->
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.xml</include>
            </includes>
            <filtering>true</filtering>
        </resource>
    </resources>
    ...
</build>


推荐阅读:
  1. mongodb配置
  2. SQL中EXPLAIN命令怎么用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

sql spring maven

上一篇:在Office 365 添加就地保留用户邮箱

下一篇:Linux系统性能监控

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》