Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The maven+mybatis+spring xml file is not compiled to the output path

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Maven+mybatis+spring encountered the following error during development:

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]: classpath resource [com/xxx/xxx/mapping/] cannot be resolved to URL because it does not exist

After checking, it is found that after maven compilation, the xml file is not packaged to the output path, resulting in the failure of bean creation.

So the solution is to add the following code to the pom file:

... Src/main/java * * / * .xml true...

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report