SpringBoot scanning MyBatis not solve the problem of mapper.xml

problem:

When the transformation of the company's existing framework SpringBoot, the original general Mybatis CRUD functionality, always scanning less than mapper.xml.

1, the structure of Java interfaces, classes, and to achieve the following xml FIG.

 

 2, Core module is defined Dao functional modules, devbench to use Dao modules.

Solution:

1, Core module defined in pom.xml increase Dao's configuration xml file compilation:

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

2, application.yml provided in the path of the scanning xml

mybatis:
  mapper-locations: classpath*:com/XXXX/**/mapper/**/*.xml

Note that mybatis is the top element, not spring subordinates !!!

3, the main class is provided MapperScan:

@MapperScan({"com.XXXX.core.dao.base,com.XXXX.core.dao.**.impl"})

 

Guess you like

Origin www.cnblogs.com/oliverreal/p/12609282.html