今天用最新的
<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 estvwtater-mybatisplus argetclasses started by vwater in C:workspace estvwtater-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:softwarejavajdkin;C:WINDOWSSunJavain;C:WINDOWSsystem32;C:WINDOWS;C:ProgramDataDockerDesktopversion-bin;C:Program FilesDockerDockerResourcesin;C:Program Files (x86)InteliCLS Client;C:Python27;C:Python27Scripts;C:Program Files (x86)Common FilesOracleJavajavapath;C:softwarejavajdkin;C:Program FilesInteliCLS Client;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:softwareGitcmd;C:softwareapache-maven-3.5.4in;C:Program FilesIntelWiFiin;C:Program FilesCommon FilesIntelWirelessCommon;C:software ortoiseSVNin;C:softwarepython;C:WINDOWSSystem32OpenSSH;C:UsersvwaterDownloadsapache-jmeter-5.0\bin;C:Program FilesAmazonAWSCLI;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsDAL;C:Program FilesIntelIntel(R) Management Engine ComponentsDAL;C:softwarepythonScripts;C:softwarepython;C:UsersvwaterAppDataLocalMicrosoftWindowsApps;C:Program FilesIntelWiFiin;C:Program FilesCommon FilesIntelWirelessCommon;;.]
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