springboot+maven+tomcat问题
来源:互联网 发布:郑州网络诈骗被一窝端 编辑:程序博客网 时间:2024/05/23 18:52
问题背景
版本介绍
jdk1.7 、springboot:1.3.1.RELEASE、tomcat8 、maven3
解决过程
1. 搭建Springboot+jsp项目。搭建Springboot项目之时,标准配置:
<modelVersion>4.0.0</modelVersion><artifactId>manage</artifactId><!--<version>1.0-SNAPSHOT</version>--><!-- 打war包,不使用springboot内置tomcat--><packaging>war</packaging> <dependencyManagement> <dependencies> <dependency> <!-- Import dependency management from Spring Boot --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.3.1.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies></dependencyManagement><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!--移除内置tomcat,打war包--> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> <!--<exclusion>--> <!--<groupId>ch.qos.logback</groupId>--> <!--<artifactId>logback-classic</artifactId>--> <!--</exclusion>--> </exclusions> </dependency> <!--Springboot的监控--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!-- Spring Boot Test 依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!--spring-boot-configuration:spring boot 配置处理器; --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> <!--关于embed的容器 使用jsp时,必须的内容--> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency> <properties> <!-- 这里指定项目编码 --> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.4.0.RELEASE</version> </plugin> <plugin> <!-- maven打包的时候告诉maven不需要web.xml,否刚会报找不到web.xml错误 --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> <plugin> <!--指定maven的编译器版本--> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build>
2. 在maven打包过程中出现了,有关ch.qos.logback版本的问题,而导致tomcat启动失败,故在pom文件中添加限制其版本
<!--logback版本问题导致tomcat启动失败--> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.1.3</version> <scope>provided</scope> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <version>1.1.3</version> <scope>provided</scope> </dependency>
3.本地启动测试没问题,放至centos6.5进行测试,手动启动linux上同版本tomcat,tomcat报错:
org.apache.jasper.servlet.TldScanner.scanJars 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.
问题来源:
使用了CKEditor和CKFinder后,在lib里添加了很多jar包,打开相应页面出现以上问题。
org.apache.jasper.compiler.TldLocationsCache tldScanJar
信息: 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.
(1)有人说是的问题,可是我的页面里根本就没有。
(2)还有说,修改${TOMCAT_HOME}/bin/catalina.sh或${TOMCAT_HOME}/bin/catalina.bat文件,可是tomcat目录下没有这两个文件。
(3)还有说,调整${tomcat}/conf/catalina.properties,将提示的jar添加到不扫描清单中。没有试,而是通过下面的方法解决了。
最终解决:
修改$CATALINA_BASE/conf/catalina.properties文件,添加org.apache.el.parser.SKIP_IDENTIFIER_CHECK=true选项。
4.上述问题解决之后发现tomcat的catalina.out虽然正常运行,并且未出现任何问题。但任然无法访问页面,通过localhost_access_log.txt日志文件返回的结果都是404,但tomcat主界面却可以正常访问。
问题原因:
linux系统jdk版本与本地版本不一致,本地版本在调试过程中无意中设置成1.8.并且将maven编译器jdk编辑版本设置成1.8.导致两地版本不一致导致。
<groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration>
5.本调试过程中最大的问题:
本地启动正常,linux启动报错如下:
06-Nov-2017 10:48:12.336 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/nrsmanage]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:976) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1853) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.helpers.NOPLoggerFactory loaded from file:/opt/nrs/apache-tomcat-8.0.47/webapps/nrsmanage/WEB-INF/lib/slf4j-api-1.7.21.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.slf4j.helpers.NOPLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext
考虑到之前有关springboot对于不同版本日志文件冲突导致启动失败的问题,故一致在本地进行关于日志工具版本的调试,都未有结果,后静下心再考虑该日志文件所说内容,随后把该web项目lib包中有关logback相关的包进行删除,tomcat正常启动,并可以正常访问。
在本地服务中,可以在pom文件中的相关包设置
<scope>provided</scope> 该标签表示该包的级别,表示仅在编译级别支持。打包和运行过程中不含有此包。
总结
1.必须时刻记住版本的重要性,以及对于tomcat原理、maven原理、以及springboot原理的深究。
2.不要盲目的相信各种解决办法,因为不管是谁的解决方法都是在特定情况下发生的,我可以借鉴他的方法,但必须要考虑清楚本地问题的原因。想清楚解决方案,在进行操作,并注意做好备份,以及对自己各种操作过程要有个记录,可以做好 Rollback操作。
- springboot+maven+tomcat问题
- Springboot+Maven+Tomcat部署
- SpringBoot问题(Tomcat启动失败)
- springboot+maven 问题小记(一)
- springboot+maven 问题小记(二)
- 使用springboot+maven出现的问题
- springboot+maven pom文件保错问题
- IntelliJ IDEA+SpringBoot+Tomcat部署404问题
- 使用 Intellij idea Springboot maven 的一个小小的问题
- Idea使用Maven创建多模块SpringBoot项目问题记录
- SpringBoot应用部署到Tomcat中无法启动问题
- SpringBoot应用部署到Tomcat中无法启动问题
- 使用Interllij Idea2017.2创建SpringBoot 启动不了Tomcat问题
- SpringBoot应用部署到Tomcat中无法启动问题
- jenkins+maven+tomcat热部署问题
- maven自动部署到tomcat的问题
- JDK Tomcat Maven 版本匹配问题
- Maven项目不能发布到Tomcat问题
- HDOJ 1236 排名
- 如何快速把多个excel表合并成一个excel表
- C#Form窗体背景透明
- java.lang.NoClassDefFoundError: xxx.xxx.xxx
- 《七点三刻》,有价值的新闻早餐。2017年11月6日,星期一
- springboot+maven+tomcat问题
- spring data redis-1
- 排序算法总结
- java基础知识(三)jvm 内存空间+对象+GC
- PyTorch笔记9-Batch Normalization
- CSS选择器
- putty访问mysql
- C# 实现Dijkstra算法
- android 架包依赖过多问题:com.android.dex.DexIndexOverflowException