Java 在Heroku上运行maven项目会导致应用程序错误
我对Maven和Heroku都是新手。我试图学习RESTfulWeb服务。因此,我在JAX-RS中创建了一个示例web应用程序,并将其部署在Heroku中。当我在本地的Tomcat8上运行它时,示例web应用程序运行得非常完美。然而,当我试图在Heroku上打开相同的web应用程序时,它会给我应用程序错误 这是我在Java 在Heroku上运行maven项目会导致应用程序错误,java,maven,tomcat,heroku,jax-rs,Java,Maven,Tomcat,Heroku,Jax Rs,我对Maven和Heroku都是新手。我试图学习RESTfulWeb服务。因此,我在JAX-RS中创建了一个示例web应用程序,并将其部署在Heroku中。当我在本地的Tomcat8上运行它时,示例web应用程序运行得非常完美。然而,当我试图在Heroku上打开相同的web应用程序时,它会给我应用程序错误 这是我在localhost:8080上运行它时得到的结果 但是当我尝试在运行相同的web应用程序时,它会给我以下错误 我很确定我错过了什么,但我不太明白是什么 下面是我的index.jsp
localhost:8080上运行它时得到的结果
但是当我尝试在运行相同的web应用程序时,它会给我以下错误
我很确定我错过了什么,但我不太明白是什么
下面是我的index.jsp
<html>
<body>
<h2>Jersey RESTful Web Application!</h2>
<p><a href="webapi/myresource">Jersey resource</a>
<p>Visit <a href="http://jersey.java.net">Project Jersey website</a>
for more information on Jersey!
</body>
</html>
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- This web.xml file is not required when using Servlet 3.0 container,
see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html -->
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.auro.self.auromovieshelf</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webapi/*</url-pattern>
</servlet-mapping>
</web-app>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.auro.self</groupId>
<artifactId>auromovieshelf</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>auromovieshelf</name>
<build>
<finalName>auromovieshelf</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>1.0.3</version>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<!-- uncomment this to get JSON support
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
-->
</dependencies>
<properties>
<jersey.version>2.23.1</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
4.0.0
org.auro.self
谢谢你抽出时间 我自己找到了解决办法。我忘了将webapprunner
插件添加到我的pom.xml
这是插件
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>copy</goal></goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>8.0.30.2</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
...
org.apache.maven.plugins
服务器的错误日志可以帮助运行heroku ps:restart
和heroku日志-t
并显示输出