@Mapper和@Repository的问题

 

 

今天用最新的

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>

<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.0.7.1</version>
</dependency>

提示找不到Mapper曾的bean,Mapper中使用@Repository

解决方案:
方案1 在启动类中添加 @MapperScan("xxx.xxx.xxx.mapper")
方案2 @Repository换成@Mapper
 
 

:: Spring Boot :: (v2.1.2.RELEASE)

2019-01-24 16:17:53.735 INFO 13800 --- [ main] c.d.v.VwtaterMybatisplusApplication : Starting VwtaterMybatisplusApplication on LAPTOP-F72VHEUV with PID 13800 (C:\workspace\test\vwtater-mybatisplus\target\classes started by vwater in C:\workspace\test\vwtater-mybatisplus)
2019-01-24 16:17:53.742 INFO 13800 --- [ main] c.d.v.VwtaterMybatisplusApplication : No active profile set, falling back to default profiles: default
2019-01-24 16:17:54.783 WARN 13800 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.djtu.vwtater]' package. Please check your configuration.
2019-01-24 16:17:55.640 INFO 13800 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-01-24 16:17:55.665 INFO 13800 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-01-24 16:17:55.665 INFO 13800 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.14]
2019-01-24 16:17:55.672 INFO 13800 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\software\java\jdk\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Docker\Docker\Resources\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\software\java\jdk\bin;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\software\Git\cmd;C:\software\apache-maven-3.5.4\bin\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\software\tortoiseSVN\bin;C:\software\python;C:\WINDOWS\System32\OpenSSH\;C:\Users\vwater\Downloads\apache-jmeter-5.0\\bin;C:\Program Files\Amazon\AWSCLI\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\software\python\Scripts\;C:\software\python\;C:\Users\vwater\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;;.]
2019-01-24 16:17:55.818 INFO 13800 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-01-24 16:17:55.818 INFO 13800 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1992 ms
2019-01-24 16:17:55.910 WARN 13800 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'employeeController': Unsatisfied dependency expressed through field 'employeeMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.djtu.vwtater.mapper.EmployeeMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2019-01-24 16:17:55.915 INFO 13800 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-01-24 16:17:55.949 INFO 13800 --- [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-01-24 16:17:56.068 ERROR 13800 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

***************************
APPLICATION FAILED TO START
***************************

Description:

Field employeeMapper in com.djtu.vwtater.controller.EmployeeController required a bean of type 'com.djtu.vwtater.mapper.EmployeeMapper' that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.djtu.vwtater.mapper.EmployeeMapper' in your configuration.

Disconnected from the target VM, address: '127.0.0.1:52242', transport: 'socket'

Process finished with exit code 1

 

转载于:https://www.cnblogs.com/vwater/p/10315217.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值