前提:(这次项目很被动,被牵着鼻子走,以至于遇到一个坑又一个坑)紧急会议支援另一个团队的前端,了解任务需求后,在外网三下五除二搭建好后台框架,功能测试完毕交付给前端,
第一个坑:前端说她在内网敲的代码,我搭建好的项目需要移到内网(内网无法联网),关键是后期部署的环境也不在内网,搞不懂她为啥写在内网,当时觉得无所谓,迁移代码就行,就做了。
第二个坑:代码迁移到内网,项目导进IDEA,maven update-----直接挂掉。。。。。。。,原因:内网的maven私服里面,jar包缺失严重,没几个jar包,尤其是我springboot2.4.1版本,内网呵呵哒,没办法,花了一天时间把一个个jar包整到maven私服仓库,项目pom文件中spring-boot-starter-parent 2.4.1版本还是报没这个文件呀,一顿百度和自研,最终只能进行降版本,根据这个maven私服目前存在的jar包情况,决定降版本为springboot2.0.6.RELEASE,然后再补一个个jar包。
第三个坑:就这样pom依赖里面硬生生多出来原来2倍的代码行,不过好在项目正常运行了,开发对接接口也是666的一批,但要部署了,打好jar包,本地运行OK,但服务器上跑不起来,1-jar包换到其他同事电脑跑,也跑不起来。2-同事本机idea中程序代码运行正常,打包成功,运行jar包依旧跑不起来。3-只有我本机打的jar包在我本机能正常运行,其他方法全失败,关键需要提的是:程序在idea中不出错,也不报错,打包也没报错,还是-success,配个图:
但就是只认我机器,只在我机器上能跑,但jar包一旦在其他机器运行,报的错不是找不到这个类就是找不到那个类,跟着报错信息走,查找代码问题,最终确定代码没问题,反正还是找不到-加载不上-启动不起来,报错信息:
rocessed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-02-24 11:44:33.627 -> [main] -> INFO o.s.boot.web.embedded.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8081 (http)
2021-02-24 11:44:33.645 -> [main] -> INFO org.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8081"]
2021-02-24 11:44:33.668 -> [main] -> INFO org.apache.catalina.core.StandardService - Starting service [Tomcat]
2021-02-24 11:44:33.669 -> [main] -> INFO org.apache.catalina.core.StandardEngine - Starting Servlet Engine: Apache Tomcat/8.5.34
2021-02-24 11:44:33.683 -> [localhost-startStop-1] -> INFO org.apache.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 (x86)\Common Files\Oracle\Java\javapath;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Java\jdk1.8.0_181\bin;C:\Program Files\Java\jre1.8.0_181\bin;D:\Git\cmd;D:\maven\apache-maven-3.6.3\bin;d:\nvm;D:\nodejs;C:\Users\yfzx_\AppData\Local\Microsoft\WindowsApps;D:\vscode\Microsoft VS Code\bin;d:\nvm;D:\nodejs;.]
2021-02-24 11:44:34.445 -> [localhost-startStop-1] -> INFO org.apache.jasper.servlet.TldScanner - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2021-02-24 11:44:34.942 -> [localhost-startStop-1] -> INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2021-02-24 11:44:34.943 -> [localhost-startStop-1] -> INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 5716 ms
2021-02-24 11:44:35.089 -> [localhost-startStop-1] -> INFO o.s.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'characterEncodingFilter' to: [/*]
2021-02-24 11:44:35.090 -> [localhost-startStop-1] -> INFO o.s.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'object' to urls: [/druid/js/common.js]
2021-02-24 11:44:35.091 -> [localhost-startStop-1] -> INFO o.s.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'webStatFilter' to urls: [/*]
2021-02-24 11:44:35.094 -> [localhost-startStop-1] -> INFO o.s.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'putFilter' to: [/*]
2021-02-24 11:44:35.095 -> [localhost-startStop-1] -> INFO o.s.boot.web.servlet.FilterRegistrationBean - Mapping filter: 'shiroFilterFactoryBean' to: [/*]
2021-02-24 11:44:35.096 -> [localhost-startStop-1] -> INFO o.s.boot.web.servlet.ServletRegistrationBean - Servlet dispatcherServlet mapped to [/]
2021-02-24 11:44:35.097 -> [localhost-startStop-1] -> INFO o.s.boot.web.servlet.ServletRegistrationBean - Servlet statViewServlet mapped to [/druid/*]
2021-02-24 11:44:35.122 -> [localhost-startStop-1] -> DEBUG com.fc.v2.common.conf.PutFilter - Filter 'putFilter' configured for use
2021-02-24 11:44:35.193 -> [main] -> WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'landResourceApprovedService' defined in URL [jar:file:/C:/Users/yfzx_/Desktop/新建文件夹%20(2)/v2.jar!/BOOT-INF/classes!/com/fc/v2/service/land/LandResourceApprovedService.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.IllegalStateException: Unable to load cache item
2021-02-24 11:44:35.198 -> [main] -> INFO org.apache.catalina.core.StandardService - Stopping service [Tomcat]
解决方法:
1:为了不影响上线,咱又把代码从内网整到外网,换回原来的2.4.1版本的pom文件,打包-部署-完美解决问题。
这就心里有个梗了,莫名其妙的原因不解决心不安啊,再一个就是内网文件拷贝到外网,外网文件拷贝到内网,这一套操作还要让专门的人员在几个楼层之间跑,不是办法啊,继续研究,花了一下午时间到5点然后能百度的百度完了,研究了一通,除了验证出文件一定出在pom依赖上之外:在外网环境打的jar包在本机外网也跑不起来,其他结果是-----准备放弃(原谅我-确实没招了)。离下班还有半小时,突然看着pom依赖突然不顺眼:原来时间紧写法是这样():
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.2.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.2.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.2.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.2.9.RELEASE</version>
</dependency>
然后也是强迫症犯了:就改成这样由这样版本统一管理<spring.version>5.2.9.RELEASE</spring.version>:
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
然后,离下班还有20分钟,继续无聊的不抱希望的抱着玩玩看的目的:IDEA运行--打包--本机启动jar包,卧槽-------启动成功了,问题解决了,我来了个大懵逼,这操作把问题解决了。。。。。。。。。。。
2:有了上面的懵逼操作经验,开始在内网电脑进行同样的操作(版本统一管理):然后发现这样操作后,内网电脑项目中:mavend的Dependencies中 突然报了缺少两个jar包:spring-oxm.jar,spring-plugin-core.jar,maven私服里面没有。。。。。,加进去后,pom里面也加进去依赖,问题解决了。
总结:这个问题搞得我又郁闷又生气又好笑,本来出现这个问题以及报的错,百度上是不可能有答案的,但一遍遍操作都不行,无意的举动竟然解决了。接下来我就是继续进行统一版本控制已完善:
<properties>
<maven-compiler-plugin.version>3.2</maven-compiler-plugin.version>
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<commons.fileupload.version>1.3.3</commons.fileupload.version>
<commons.io.version>2.5</commons.io.version>
<jstl.version>1.2</jstl.version>
<taglibs.version>1.1.2</taglibs.version>
<tomcat-embed-jasper.version>8.5.34</tomcat-embed-jasper.version>
<servlet-jsp-api.version>2.3.1</servlet-jsp-api.version>
<spring.version>5.2.9.RELEASE</spring.version>
</properties>
整个问题下来:缺少的两个jar包在没有的情况下,以前也能正常运行,打包,证明缺失的jar包是不影响程序运行的,但就是部署jar包不成功,但版本统一管理之后才暴露出来了缺少jar包情况,这个情况到底是什么原因?清楚的小伙伴还请告知。