我没有在Java,SpringBoot和Maven上做很多工作。我已经针对上述问题浏览了几篇文章,但是没有什么比我的情况要好
我在Windows 10上使用Maven with JDK1.8.0_172
编译并打包SpringBoot项目
然后我将打包好的战争部署到Linux服务器(RHEL with JDK1.8.0_201 and Tomcat 8
)
当我点击URL http://localhost:8080/MyApp时,tomcat错误,并且在Tomcat日志中没有发现任何错误
我不确定自己在做什么错。任何帮助都将受到高度赞赏
Tomcat服务器错误
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
POM.xml文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.htc.myapp.main</groupId>
<artifactId>SpringProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.bmc.remedy</groupId>
<artifactId>remedyapi</artifactId>
<version>8.1</version>
<scope>system</scope>
<systemPath>${basedir}/lib/remedyapi-8.1.jar</systemPath>
</dependency>
<!-- JSTL tag lib -->
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>javax.servlet.jsp.jstl-api</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
<!-- <dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency> -->
<!-- Tomcat for JSP rendering -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.8.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<!-- <dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency> -->
<!--
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency> -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!-- <dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.3</version>
</dependency> -->
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-client -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
</dependencies>
<build>
<finalName>MyApp</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>
<procedure><packaging>war</packaging></properties>
</project>
编辑
我安装了Tomcat 7,并且能够打开该应用程序。但是,对应用程序执行某些操作会引发“出了点问题”
查看Tomcat日志,似乎数据库连接存在问题
日志错误
2019-06-19 12:42:55.943 ERROR 20177 --- [bio-8080-exec-3] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
java.sql.SQLException: No suitable driver found for jdbc:jtds:sqlserver://10.xxx.xxx.xxx:1433/MyDatabase;user=username;password=pwd
我将jtds-1.3.1.jar复制到$ TOMCAT_instance / lib目录,并尝试使用以下数据库设置,但没有任何作用起作用
db_LMS.url=jdbc:jtds:sqlserver://10.xxx.xxx.xxx:1433;databaseName=MyDatabase;integratedSecurity=true;user=username;password=pwd
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
db_LMS.url=jdbc:jtds:sqlserver://10.xxx.xxx.xxx:1433/MyDatabase;user=username;password=pwd
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
在此问题上的任何帮助都将受到赞赏
答案 0 :(得分:0)
此错误仅表示没有“代码可处理”与您键入的URL相关的请求。通常,tomcat不会记录这些尝试,因为它们不会真正添加任何有人试图访问不存在的资源的有用信息,那怎么办?
检查部署应用程序的上下文路径,可能不是MyApp
,而是其他内容?
还要检查您的请求是否确实有效(发出正确的HTTP方法,发送正确的标头等)。
最后但并非最不重要的一点,请确保在Spring应用程序的启动日志中确实在启动过程中被Spring识别出控制器(您应该看到url
映射到some info about the controller
之类的东西)。 / p>
另一个可能的原因是该资源受保护并且没有凭据之类的某种标识就无法访问。在这种情况下,还应检查安全性配置(由于它本身是一个非常广泛的主题,因此我认为在这个问题的上下文中我不能更加具体)。
答案 1 :(得分:0)
在$ TOMCAT_HOME / conf / server.xml中添加了以下内容,以解决此问题
默认情况下,Tomcat禁用加载Java驱动程序文件以防止内存泄漏问题
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" driverManagerProtection="false" />