Java Heroku错误:spring引导应用程序的JAR文件中没有主清单属性

Java Heroku错误:spring引导应用程序的JAR文件中没有主清单属性,java,spring-boot,maven,heroku,jar,Java,Spring Boot,Maven,Heroku,Jar,我想将我的spring boot应用程序部署到Heroku,我按照步骤创建了jar文件-Survey-0.0.1-SNAPSHOT.jar。该应用程序在本地运行良好,还可以通过以下方式运行该应用程序: heroku local web 很好。使用 java -jar target/Survey-0.0.1-SNAPSHOT.jar 此外,它还可以很好地显示: . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ _

我想将我的spring boot应用程序部署到Heroku,我按照步骤创建了jar文件-Survey-0.0.1-SNAPSHOT.jar。该应用程序在本地运行良好,还可以通过以下方式运行该应用程序:

heroku local web 
很好。使用

java -jar target/Survey-0.0.1-SNAPSHOT.jar
此外,它还可以很好地显示:


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.4.5)

2021-05-08 15:36:07.685  INFO 23710 --- [           main] survey.SurveyApplication                 : Starting SurveyApplication v0.0.1-SNAPSHOT using Java 16.0.1 on karthikey with PID 23710 (/home/karthikey/Desktop/JavaPrograms/Survey/target/Survey-0.0.1-SNAPSHOT.jar started by karthikey in /home/karthikey/Desktop/JavaPrograms/Survey)
2021-05-08 15:36:07.688  INFO 23710 --- [           main] survey.SurveyApplication                 : No active profile set, falling back to default profiles: default
2021-05-08 15:36:08.455  INFO 23710 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-05-08 15:36:08.534  INFO 23710 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 69 ms. Found 4 JPA repository interfaces.
2021-05-08 15:36:08.925  INFO 23710 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@4e423aa2' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-05-08 15:36:08.928  INFO 23710 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-05-08 15:36:09.188  INFO 23710 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-05-08 15:36:09.200  INFO 23710 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-05-08 15:36:09.200  INFO 23710 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.45]
2021-05-08 15:36:09.247  INFO 23710 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-05-08 15:36:09.247  INFO 23710 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1513 ms
2021-05-08 15:36:09.334  WARN 23710 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-05-08 15:36:09.476  INFO 23710 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-05-08 15:36:09.537  INFO 23710 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.30.Final
2021-05-08 15:36:09.659  INFO 23710 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-05-08 15:36:09.758  INFO 23710 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-05-08 15:36:14.569  INFO 23710 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-05-08 15:36:14.588  INFO 23710 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2021-05-08 15:36:17.448  INFO 23710 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-05-08 15:36:17.460  INFO 23710 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-05-08 15:36:18.357  INFO 23710 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@2f7efd0b, org.springframework.security.web.context.SecurityContextPersistenceFilter@53a7a60c, org.springframework.security.web.header.HeaderWriterFilter@3ae126d1, org.springframework.web.filter.CorsFilter@41ad373, org.springframework.security.web.authentication.logout.LogoutFilter@326d27ac, survey.security.jwt.AuthTokenFilter@1a1f5f71, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6a87026, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@2503ec73, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@6801b414, org.springframework.security.web.session.SessionManagementFilter@43fda8d9, org.springframework.security.web.access.ExceptionTranslationFilter@3e4e4c1, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@69f0b0f4]
2021-05-08 15:36:18.434  INFO 23710 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-05-08 15:36:18.598  INFO 23710 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-05-08 15:36:18.608  INFO 23710 --- [           main] survey.SurveyApplication                 : Started SurveyApplication in 11.38 seconds (JVM running for 11.803)
但是当我使用

git push heroku master
应用程序已成功构建,显示:

Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 310 bytes | 310.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/java
remote: -----> Java app detected
remote: -----> Installing JDK 1.8... done
remote: -----> Executing Maven
remote:        $ ./mvnw -DskipTests clean dependency:list install
remote:        [INFO] Scanning for projects...
remote:        [INFO] 
remote:        [INFO] -------------------------< com.example:Survey >-------------------------
remote:        [INFO] Building Survey 0.0.1-SNAPSHOT
remote:        [INFO] --------------------------------[ jar ]---------------------------------
remote:        [INFO] 
remote:        [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ Survey ---
remote:        [INFO] 
remote:        [INFO] --- maven-dependency-plugin:3.1.2:list (default-cli) @ Survey ---
remote:        [INFO] 
remote:        [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ Survey ---
remote:        [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote:        [INFO] Using 'UTF-8' encoding to copy filtered properties files.
remote:        [INFO] Copying 1 resource
remote:        [INFO] Copying 2 resources
remote:        [INFO] 
remote:        [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ Survey ---
remote:        [INFO] Changes detected - recompiling the module!
remote:        [INFO] Compiling 27 source files to /tmp/build_f97fc166/target/classes
remote:        [INFO] 
remote:        [INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ Survey ---
remote:        [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote:        [INFO] Using 'UTF-8' encoding to copy filtered properties files.
remote:        [INFO] skip non existing resourceDirectory /tmp/build_f97fc166/src/test/resources
remote:        [INFO] 
remote:        [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ Survey ---
remote:        [INFO] Changes detected - recompiling the module!
remote:        [INFO] Compiling 1 source file to /tmp/build_f97fc166/target/test-classes
remote:        [INFO] 
remote:        [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ Survey ---
remote:        [INFO] Tests are skipped.
remote:        [INFO] 
remote:        [INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ Survey ---
remote:        [INFO] Building jar: /tmp/build_f97fc166/target/Survey-0.0.1-SNAPSHOT.jar
remote:        [INFO] 
remote:        [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ Survey ---
remote:        [INFO] Installing /tmp/build_f97fc166/target/Survey-0.0.1-SNAPSHOT.jar to /tmp/codon/tmp/cache/.m2/repository/com/example/Survey/0.0.1-SNAPSHOT/Survey-0.0.1-SNAPSHOT.jar
remote:        [INFO] Installing /tmp/build_f97fc166/pom.xml to /tmp/codon/tmp/cache/.m2/repository/com/example/Survey/0.0.1-SNAPSHOT/Survey-0.0.1-SNAPSHOT.pom
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] BUILD SUCCESS
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] Total time:  5.861 s
remote:        [INFO] Finished at: 2021-05-08T08:34:54Z
remote:        [INFO] ------------------------------------------------------------------------
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote: 
remote: -----> Compressing...
remote:        Done: 51.9M
remote: -----> Launching...
remote:        Released v34
remote:        https://survey-it-up.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/survey-it-up.git
   1dddca6..dfc71c2  master -> master

我的文件:

web: java -jar target/Survey-0.0.1-SNAPSHOT.jar
我还在MANIFEST.MF文件中指定了main类,它在本地运行良好。 我的MANIFEST.MF文件:

Manifest-Version: 1.0
Created-By: Maven Jar Plugin 3.2.0
Build-Jdk-Spec: 16
Implementation-Title: Survey
Implementation-Version: 0.0.1-SNAPSHOT
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: survey.SurveyApplication
Spring-Boot-Version: 2.4.5
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Spring-Boot-Classpath-Index: BOOT-INF/classpath.idx
Spring-Boot-Layers-Index: BOOT-INF/layers.idx

pom.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>Survey</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>Survey</name>
    <description>A web application for hoisting surveys</description>
    <properties>
        <java.version>8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.9.1</version>
        </dependency>
    </dependencies>

    <build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
    </build>

</project>

并且它会以某种方式更改MANIFEST.MF文件,比如使用默认的MANIFEST.MF,它不包含main类属性。我不明白为什么即使在指定了主类之后,它也没有给出主清单错误。请帮助我。

我通过删除pom.xml文件的build部分下的
解决了这个错误。似乎Heroku没有读取
,删除后,应用程序成功部署到Heroku。移除标记后,我执行了以下步骤:

mvn package
上面的命令构建项目并将生成的JAR文件打包到目标目录中,然后运行

git push heroku master
将应用程序推送到Heroku

注意:我把插件放在
下面,因为Eclipse在插件上显示了一个错误,但即使这样,程序仍然在运行。因此,似乎对
标记没有要求

mvn package
git push heroku master