Unsatisfied dependency expressed through field 'baseMapper'解决方法

Framework: Spring Boot + Mybatis Plus
to run the project today, when the project always get up, has been an error

 Unsatisfied dependency expressed through bean property 'sqlSessionFactory'
 Unsatisfied dependency expressed through field 'baseMapper'

Crazy reported two errors, based on previous experience should be Mapper I have not been scanned, not scanned if there is no way to create, so I checked to see if the first step @MapperScan ( "com.xx. xx ")

  1. Mapper see you have not been scanned, I myself added a comment @MapperScan ( "com.xx.xx") This form, com.xx.xx package is the package name of your Mapper where
    the code can refer to the following I wrote a configuration class.
@Configuration
@MapperScan("com.xx.xx")
public class MybatisPlusConfig {}

I found this step without any problems, so I started again of course being given, vomiting blood.

  1. Then I checked my profile inside look mybatis mapping files have no write to
mybatis-plus:
  mapper-locations: classpath*:/com/xx/xx/xx/xml/*.xml
  type-aliases-package: com.zctt.menu.entity
  global-config:
    banner: false
    db-config:
      id-type: input

I took a look and there is no problem.
3. Thinking again then I will pack my xml file does not come in, then looked under my pom file inside

   <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <filtering>false</filtering>
                <includes>
                    <include>com/xx/xx/mapper/xml/*.xml</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

This is very strange and I packed up, look inside the target is to have my xml file.

Finally, look at the log to see such a sentence

The XML location is ‘file [E:\wl\workspace\menu\menu-mapper\target\classes\com\xx\xx\mapper\xml\MenuMapper.xml]’. Cause: org.apache.ibatis.builder.BuilderException: Parsing error was found in mapping #{}.

I will not be a problem inside the xml file to see the results of it for a moment.
Here Insert Picture Description
I really xml file which is a problem, here was writing too quickly, wrote a leak, then get rid of after the program ran up
Here Insert Picture Description

to sum up

  1. Take a look at @MapperScan ( "com.xx.xx.xx") or above on the interface mapper plus @Mapper also OK
  2. Take a look at the configuration file which maps have not written
  3. Take a look at the compiled file, there are no xml file, if not packaged maven is not compiled into the xml file below, add the following code in the code inside it.
      <resources>
          <resource>
              <directory>src/main/java</directory>
              <filtering>false</filtering>
              <includes>
                  <include>com/xx/xx/mapper/xml/*.xml</include>
              </includes>
          </resource>
      </resources>
  </build>
  1. Look at your xml file there are no labels or anything wrong, check to check your xml file.

Also remember to take a look at the log, I did not see the log on when, let my hair has a few less! ! ! !

Not a programmer writing is not a good playing field.
I welcome the focus on micro-channel public number ah: Thousand Jue, what the problem back a message to me, to see will be back.

Published 11 original articles · won praise 75 · views 6945

Guess you like

Origin blog.csdn.net/zjwl199802/article/details/103713864