关于SpringBoot启动失败问题

来源:4-2 UserProductDao的开发与测试

Robot大冰

2020-05-01 11:14:15

老师,我把V2的源码直接导入了STS,修改了所有的包名,现在是com.hbut.xxx,代码里面也全都替换了,所有的XML文件里面也都替换了,运行项目一直提示productSellDailyDao这个找不到,但我核对了确实没问题,下面是console所有的信息,你看看:

2020-05-01 11:05:25.077 [main] INFO  com.hbut.o2o.O2oApplication - Starting O2oApplication on PauperGuy的Lenovo with PID 10884 (E:\o2o\target\classes started by huang in E:\o2o)
2020-05-01 11:05:25.080 [main] DEBUG com.hbut.o2o.O2oApplication - Running with Spring Boot v1.5.8.RELEASE, Spring v4.3.12.RELEASE
2020-05-01 11:05:25.081 [main] INFO  com.hbut.o2o.O2oApplication - No active profile set, falling back to default profiles: default
2020-05-01 11:05:25.134 [main] INFO  o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6156496: startup date [Fri May 01 11:05:25 CST 2020]; root of context hierarchy
2020-05-01 11:05:25.414 [background-preinit] INFO  org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 5.3.5.Final
2020-05-01 11:05:25.985 [main] WARN  org.mybatis.spring.mapper.ClassPathMapperScanner - No MyBatis mapper was found in '[com.imooc.o2o.dao]' package. Please check your configuration.
2020-05-01 11:05:26.226 [main] WARN  org.mybatis.spring.mapper.ClassPathMapperScanner - No MyBatis mapper was found in '[com.hbut.o2o]' package. Please check your configuration.
2020-05-01 11:05:26.650 [MLog-Init-Reporter] INFO  com.mchange.v2.log.MLog - MLog clients using slf4j logging.
2020-05-01 11:05:27.253 [main] INFO  com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
2020-05-01 11:05:28.620 [main] INFO  o.s.b.c.e.tomcat.TomcatEmbeddedServletContainer - Tomcat initialized with port(s): 8081 (http)
2020-05-01 11:05:28.634 [main] INFO  org.apache.catalina.core.StandardService - Starting service [Tomcat]
2020-05-01 11:05:28.635 [main] INFO  org.apache.catalina.core.StandardEngine - Starting Servlet Engine: Apache Tomcat/8.5.23
2020-05-01 11:05:28.807 [localhost-startStop-1] INFO  o.a.c.c.ContainerBase.[Tomcat].[localhost].[/o2o] - Initializing Spring embedded WebApplicationContext
2020-05-01 11:05:28.808 [localhost-startStop-1] INFO  org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 3674 ms
2020-05-01 11:05:28.971 [localhost-startStop-1] INFO  o.s.boot.web.servlet.ServletRegistrationBean - Mapping servlet: 'kaptchaServlet' to [/Kaptcha]
2020-05-01 11:05:28.973 [localhost-startStop-1] INFO  o.s.boot.web.servlet.ServletRegistrationBean - Mapping servlet: 'dispatcherServlet' to [/]
2020-05-01 11:05:28.977 [localhost-startStop-1] INFO  o.s.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'characterEncodingFilter' to: [/*]
2020-05-01 11:05:29.032 [main] WARN  o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'quartzConfiguration': Unsatisfied dependency expressed through field 'productSellDailyService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productSellDailyServiceImpl': Unsatisfied dependency expressed through field 'productSellDailyDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.hbut.o2o.dao.ProductSellDailyDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2020-05-01 11:05:29.035 [main] INFO  org.apache.catalina.core.StandardService - Stopping service [Tomcat]
2020-05-01 11:05:29.049 [main] INFO  o.s.b.a.l.AutoConfigurationReportLoggingInitializer - 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2020-05-01 11:05:29.151 [main] ERROR o.s.b.diagnostics.LoggingFailureAnalysisReporter - 

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

Description:

Field productSellDailyDao in com.hbut.o2o.service.impl.ProductSellDailyServiceImpl required a bean of type 'com.hbut.o2o.dao.ProductSellDailyDao' that could not be found.


Action:

Consider defining a bean of type 'com.hbut.o2o.dao.ProductSellDailyDao' in your configuration.

另外,项目的名字前面有个x,但是下面的所有文件都没错误,

http://img.mukewang.com/climg/5eab93f40923242904430564.jpg


麻烦帮我看看,谢谢老师

写回答

7回答

好帮手慕阿满

2020-05-07

同学你好,如下报错提示是指链接mysql时的密码错误,问一下同学有修改源码中的数据库密码为自己的数据库密码吗?

http://img.mukewang.com/climg/5eb3813d09d9c5dd07740232.jpg

如果没有修改一下再试试。

使用STS,也要修改Tomcat的server。

祝:学习愉快~

0

好帮手慕阿满

2020-05-06

同学你好,server.xml文件是指tomcat下的server.xml文件,如:

http://img.mukewang.com/climg/5eb2a0b909bc111104820312.jpg

关于路径问题,同学可以参考如下的配置

http://img.mukewang.com/climg/5eb2a2200914a01107470594.jpg

建议同学根据配置文件调整一下,如:

http://img.mukewang.com/climg/5eb2a23a09c07cec04360126.jpg

超级管理员提示“请求失败”,问一下同学输入的用户名和密码是否正确。同学有使用MD5测试123456加密后的密文和数据库的密码一致吗?

建议同学检查一下。

祝:学习愉快~

0
hobot大冰
h STS里面也报错: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
h020-05-06
共4条回复

好帮手慕阿满

2020-05-06

同学你好,问一下同学是否启动了redis,项目将会从缓存中读取数据,如果没有开启redis,会无法显示图片,无法加载数据等。

另外关于店家和管理员的密码应该是:123456,这里是使用MD5进行加密的。同学可以在utils包下的MD5类中测试一下,查看加密后的数据和数据库中存储的是否一样,如:

http://img.mukewang.com/climg/5eb2802909eef7f605910356.jpg

如果不一致,同学可以修改一下数据库中的数据。

如果我的回答解决了你的疑惑,请采纳。祝:学习愉快~

0
hobot大冰
h 老师,Redis启动了也是没有数据,我觉得是我文件路径有问题但不知道怎么改,因为2.0的项目我没找到PathUtil里的路径,还有server.xml。 另外密码我输入123456也无法登陆,超级管理员系统提示“请求失败”,店家管理没反应,
h020-05-06
共1条回复

好帮手慕阿满

2020-05-06

同学你好,建议同学在如下的O2oApplication类中加上@MapperScan(value = "com.hbut.o2o.dao")注解试试。如:

http://img.mukewang.com/climg/5eb229b009515ca804440228.jpg

另外同学现在还有什么错误,建议同学将错误再详细描述一下。

祝:学习愉快~

0
hobot大冰
h 终于解决了,谢谢老师,现在启动后浏览器访问,首页没有图片显示,点击“全部商店”进入商店列表后,一直在加载,但是加载不出来任何数据,这是什么原因呢?数据库也连接了。另外,问一下老师,店家管理和超级管理员的账号密码,我看数据库里面加密过。
h020-05-06
共1条回复

好帮手慕阿满

2020-05-05

同学你好,建议同学在启动类O2oApplication的类名上加上如下注解再试试:

 @MapperScan(value = "com.hbut.o2o.dao")

如果我的回答解决了你的疑惑,请采纳。祝:学习愉快~

0
hobot大冰
h 老师,这个文件的路径在哪?我找了好久都找不到。另外老师能不能帮我看一下上面的报错信息,我觉得错误很多但是不知道怎么解决
h020-05-05
共1条回复

好帮手慕小班

2020-05-01

同学你好,根据同学的报错信息,分别是:

    1、无法将动态项目修改为3.1的版本。

        同学可以参考如下形式修改一下版本:

  1)、 更改setting目录下的配置:

http://img.mukewang.com/climg/5eabfb4109a5b49e03620288.jpg

 去掉勾选 .* resources ,点击OK按钮:

http://img.mukewang.com/climg/5eabfb860993639e04380553.jpg

选择项目根目录下出现setting目录:

http://img.mukewang.com/climg/5eabfd6b0998df9c04370233.jpg

修改这个配置文件,将jst.web一项改为3.1:

http://img.mukewang.com/climg/5eabfcda09bd890b04730170.jpg

        2)、修改项目的facets

项目右键 -> Properties -> Project Facets,把Dynamic Web Module 一项修改为3.1:

http://img.mukewang.com/climg/5eabfe30096dbaab08750607.jpg

        3)、检查修改\WEB-INF\web.xml 为对应的3.1

http://img.mukewang.com/climg/5eabfeb609929e4e10090129.jpg

        4)、最后清理缓存,再来重新加载一下maven项目。项目右键 -> Maven -> Update Projects

    2、java的编译器与当前项目的版本不匹配。

由于jdk的版本不匹配导致,同学可以检查一下自己的jdk配置,例如:

右击项目选择Build Path--? Configure.....

http://img.mukewang.com/climg/5eabff4109ee10bc07250168.jpg

检查修改为自己对应的jdk。

http://img.mukewang.com/climg/5eabffb209c3092408580467.jpg

    3、一个或者多个约束没有被满足。这个问题也有可能是jdk版本不一致造成的,同学可以尝试修改后再看看。

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~

0
hobot大冰
h Action: Consider defining a bean of type 'com.hbut.o2o.dao.ProductSellDailyDao' in your configuration.
h020-05-01
共2条回复

好帮手慕小班

2020-05-01

同学你好,同学可以调出Problem窗口查看具体的报错信息,比如:

http://img.mukewang.com/climg/5eabdbe00957e35005370531.jpg

http://img.mukewang.com/climg/5eabdc1c096954aa02990114.jpg

查看具体的报错信息有什么。

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~

0
hobot大冰
h 1.Cannot change version of project facet Dynamic Web Module to 3.1. 2.Java compiler level does not match the version of the installed Java project facet. 3.One or more constraints have not been satisfied. 三个问题老师看看
h020-05-01
共1条回复

0 学习 · 8263 问题

查看课程