gpt4 book ai didi

java - 部署到heroku时,它在pom.xml中看不到我的jar文件或maven依赖项

转载 作者:行者123 更新时间:2023-11-30 06:15:56 25 4
gpt4 key购买 nike

我正在尝试使用heroku网站部署我的应用程序,但它没有看到任何像HttpServlet这样的maven依赖项尽管我有它在我的pom.xml中 并且它没有看到 Gson.jar 尽管它位于 lib 目录中。我添加了 webapp-runner 插件,但什么也没发生。这是我得到的错误。感谢您的帮助。谢谢大家。

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[6,21] package javax.servlet does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[7,26] package javax.servlet.http does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[8,26] package javax.servlet.http does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[9,26] package javax.servlet.http does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[11,48] package com.sun.javafx.collections.MappingChange does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[13,40] cannot find symbol
symbol: class HttpServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[15,30] cannot find symbol
symbol: class HttpServletRequest
location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[15,54] cannot find symbol
symbol: class HttpServletResponse
location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[15,87] cannot find symbol
symbol: class ServletException
location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[24,64] cannot find symbol
symbol: class HttpServletRequest
location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDeals.java:[14,23] package com.google.gson does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDeals.java:[15,48] package com.sun.javafx.collections.MappingChange does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/Deals.java:[6,48] package com.sun.javafx.collections.MappingChange does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[14,9] method does not override or implement a method from a supertype
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDeals.java:[26,38] cannot find symbol
symbol: class Gson
location: class hotels.HotelDeals
[INFO] 15 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.514 s
[INFO] Finished at: 2018-03-09T16:25:19+00:00
[INFO] Final Memory: 19M/177M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project hotels: Compilation failure: Compilation failure:
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[6,21] package javax.servlet does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[7,26] package javax.servlet.http does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[8,26] package javax.servlet.http does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[9,26] package javax.servlet.http does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[11,48] package com.sun.javafx.collections.MappingChange does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[13,40] cannot find symbol
[ERROR] symbol: class HttpServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[15,30] cannot find symbol
[ERROR] symbol: class HttpServletRequest
[ERROR] location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[15,54] cannot find symbol
[ERROR] symbol: class HttpServletResponse
[ERROR] location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[15,87] cannot find symbol
[ERROR] symbol: class ServletException
[ERROR] location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[24,64] cannot find symbol
[ERROR] symbol: class HttpServletRequest
[ERROR] location: class hotels.HotelDealsServlet
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDeals.java:[14,23] package com.google.gson does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDeals.java:[15,48] package com.sun.javafx.collections.MappingChange does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/Deals.java:[6,48] package com.sun.javafx.collections.MappingChange does not exist
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDealsServlet.java:[14,9] method does not override or implement a method from a supertype
[ERROR] /tmp/build_d6140010f65ec320b1605ee2b8276832/khalidCS-deals-hotel-fa63bfd/src/main/java/hotels/HotelDeals.java:[26,38] cannot find symbol
[ERROR] symbol: class Gson
[ERROR] location: class hotels.HotelDeals
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
! ERROR: Failed to build app with Maven
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/
! Push rejected, failed to compile Java app.
! Push failed

添加OP在答案部分发布的POM

<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.khalid.hotels</groupId>
<artifactId>hotels</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>embeddedTomcatSample Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<tomcat.version>8.5.23</tomcat.version>
</properties>
<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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

最佳答案

请使用下面更新的 POM:

<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.khalid.hotels</groupId>
<artifactId>hotels</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>embeddedTomcatSample Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<tomcat.version>8.5.23</tomcat.version>
</properties>
<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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
</dependencies>
</project>

关于java - 部署到heroku时,它在pom.xml中看不到我的jar文件或maven依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49198470/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com