2018-07-24 15:38:07.647 INFO 20368 --- [ main] c.e.playspring.PlayspringApplication : Starting PlayspringApplication on LAPTOP-P96OGO0J with PID 20368 (C:\project\playspring\target\classes started by DK in C:\project\playspring)
2018-07-24 15:38:07.651 INFO 20368 --- [ main] c.e.playspring.PlayspringApplication : No active profile set, falling back to default profiles: default
2018-07-24 15:38:07.729 INFO 20368 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@13e39c73: startup date [Tue Jul 24 15:38:07 CST 2018]; root of context hierarchy
2018-07-24 15:38:08.376 WARN 20368 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.sam.project.*.mapper]' package. Please check your configuration.
2018-07-24 15:38:08.518 WARN 20368 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.example.playspring]' package. Please check your configuration.
2018-07-24 15:38:09.307 INFO 20368 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8088 (http)
2018-07-24 15:38:09.344 INFO 20368 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-07-24 15:38:09.345 INFO 20368 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-07-24 15:38:09.350 INFO 20368 --- [ost-startStop-1] 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:\Program Files\Java\jdk1.8.0_171\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Java\jdk1.8.0_171\bin;C:\Program Files\Java\jdk1.8.0_171\jre\bin;C:\Program Files\Git\cmd;C:\Users\DK\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Bandizip\;.]
2018-07-24 15:38:09.533 INFO 20368 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-07-24 15:38:09.533 INFO 20368 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1806 ms
2018-07-24 15:38:09.816 INFO 20368 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-24 15:38:09.817 INFO 20368 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-24 15:38:09.818 INFO 20368 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-24 15:38:09.818 INFO 20368 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-24 15:38:09.819 INFO 20368 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-07-24 15:38:09.820 INFO 20368 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-07-24 15:38:09.874 WARN 20368 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService': Unsatisfied dependency expressed through field 'userMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.playspring.mapper.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2018-07-24 15:38:09.876 INFO 20368 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-07-24 15:38:09.909 INFO 20368 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-07-24 15:38:10.027 ERROR 20368 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field userMapper in com.example.playspring.service.UserService required a bean of type 'com.example.playspring.mapper.UserMapper' that could not be found.
Action:
Consider defining a bean of type 'com.example.playspring.mapper.UserMapper' in your configuration.
因为刚开始玩spring boot ,也具有很多独特的注解,遇到了一些问题。目前demo跑起来了~
spring boot + mybatis 配置参考:https://blog.csdn.net/vtopqx/article/details/77719130#commentsedit
不过代码中启动类中缺少内容
解决办法:
在主函数类上添加以上注解,可以扫描dao包中的所有接口,替代在每个dao中写@Mapper注解,这样会提高耦合度。
加上@MapperScan注解 后面是mapper接口的类的地址
@MapperScan("com.example.playspring.mapper")
@MapperScan的理解:使用该注解,可以免去每个Mapper类都加上@Mapper
这个注解也可以同时扫描多个包,
如果如果mapper类没有在Spring Boot主程序可以扫描的包或者子包下面,可以使用如下方式进行配置
- @SpringBootApplication
- @MapperScan({"com.example.*.mapper","org.example.*.mapper"})
- public class App {
- public static void main(String[] args) {
- SpringApplication.run(App.class, args);
- }
- }