1.问题解决后原因分析:maven依赖的问题,jar包版本或者jar没有下载下来的问题,因为同一个项目别人电脑可以正常启动,但是自己的电脑上就启动报错,分析只有跟每个人本地maven仓库有关。
2.我的这次的问题分析:是jar包版本问题,而不是jar没有下载下来导致的,因为如果是jar没有下载好的话,启动项目的时候可以通过Eclispe中Problems窗口进行查看,上面会提示那个jar包依赖没有下载好,这次我的问题在Problems窗口并没有看到此等报错信息,所以启动项目通过console窗口看到UnsatisfiedDependencyException,NoClassDefFoun等信息报错,判断是jar包版本问题,具体控制台报错信息如下:
Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'jwtAuthenticationTokenFilter': Unsatisfied dependency expressed through field 'tokenService';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tokenService': Unsatisfied dependency expressed through field 'redisCache';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisCache': Unsatisfied dependency expressed through field 'redisTemplate';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisTemplate' defined in class path resource [comyi/framework/config/RedisConfig.class]: Unsatisfied dependency expressed through method 'redisTemplate' parameter 0;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.class]: Unsatisfied dependency expressed through method 'redisConnectionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lettuceClientResources' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.class]: Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.lettuce.core.resource.DefaultClientResources]: Factory method 'lettuceClientResources' threw exception;
nested exception is java.lang.NoClassDefFoundError: io/netty/util/Timer
3.怎么看或者怎么找出是那些jar包出现了问题?
方法流程:Eclispe中该项目右键 ==》 Run As ==》 Maven Install,之后查看console窗口具体信息,我的信息具体如下:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.ruoyi:ruoyi >---------------------------
[INFO] Building ruoyi 2.1.0
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.springframework:spring-tx:jar:5.1.3.RELEASE is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for io.lettuce:lettuce-core:jar:5.1.3.RELEASE is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for commons-codec:commons-codec:jar:1.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ ruoyi ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Copying 32 resources
[INFO]
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
a.从这次报错信息可知:BUILD FAILURE,具体原因是[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
b.把项目环境从JRE换成JDK后,BUILD SUCCESS,通过console窗口可以看到Jar的[WARNING](这些具体jar就是造成项目启动不了的直接原因),这次具体WARNING如下:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.ruoyi:ruoyi >---------------------------
[INFO] Building ruoyi 2.1.0
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for io.lettuce:lettuce-core:jar:5.1.3.RELEASE is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for commons-codec:commons-codec:jar:1.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] --- maven-jar-plugin:3.1.0:jar (default-jar) @ ruoyi ---
[WARNING] The POM for org.apache.commons:commons-compress:jar:1.14 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.1.RELEASE:repackage (repackage) @ ruoyi ---
[WARNING] The POM for commons-io:commons-io:jar:2.6 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32.766 s
[INFO] Finished at: 2020-03-05T10:50:48+08:00
[INFO]
c.一个有四个[WARNING],此次我问题得到解决就是在项目的pom文件中,把这些WARNING的jar包的依赖换成了其他版本,依赖版本可以参考Maven官网:https://mvnrepository.com/ 原则是那个版本用的人多就换那个。
4.希望能帮到需要的朋友。