maven+mybatis+spring XML file not compiled to output path

Source: Internet
Author: User

Maven+mybatis+spring encountered the following error while developing:


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 beans with Name ' Xxxmapper ' defined in file [Xxxmapper.class]: Cannot resolve reference to beans ' sqlsessionfactory ' while setting bean property ' Sqlse Ssionfactory '; Nested exception is org.springframework.beans.factory.BeanCreationException:Error creating beans 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.C Ore.io.resource[] ' for property ' mapperlocations '; Nested exception is java.lang.IllegalArgumentException:Could no resolve resource location pattern [classpath:com/xxx/ Xxx/mapping/*.xml]: Class PATH resource [com/xxx/xxx/mapping/] cannot is resolved to URL because it does not exist


After checking that Maven compiled and did not package the XML file to the output path, the bean creation failed.

So the workaround is to add the following code to the Pom file:

<build> ... <resources> <!--include xml--> <resource> <DIRECTORY&G after compilation            T;src/main/java</directory> <includes> <include>**/*.xml</include>    </includes> <filtering>true</filtering> </resource> </resources> ...</build>


Maven+mybatis+spring XML file not compiled to output path

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.