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