Heroku无法实现主要class

Heroku could not be able to realize the main class

以下是我的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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.luckypants</groupId>
    <artifactId>LuckyPants</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>LuckyPants</name>

    <properties>
        <tomcat.version>7.0.34</tomcat.version>
        <jersey.version>1.8</jersey.version>
        <target.version>1.7</target.version>
        <appassembler.version>1.8</appassembler.version>
        <source.version>1.7</source.version>
        <mvn.compiler.version>3.0</mvn.compiler.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <!--<dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> 
            <version>${jersey.version}</version> </dependency> -->
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" -->
            <artifactId>jersey-container-servlet</artifactId>
            <version>2.14</version>
        </dependency>
        <!-- if you are using Jersey client specific features without the server 
            side -->
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.14</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.connectors</groupId>
            <artifactId>jersey-apache-connector</artifactId>
            <version>2.14</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.14</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-core</artifactId>
            <version>${tomcat.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-logging-juli</artifactId>
            <version>${tomcat.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <version>${tomcat.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jasper</artifactId>
            <version>${tomcat.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jasper-el</artifactId>
            <version>${tomcat.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jsp-api</artifactId>
            <version>${tomcat.version}</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>LuckyPants</finalName>
        <plugins>
            <!-- <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> 
                <configuration> <warSourceDirectory>src/main/java/com</warSourceDirectory> 
                <webResources> <resource> <directory>WebContent</directory> </resource> </webResources> 
                </configuration> </plugin> -->
            <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>7.0.40.0</version>
                                    <destFileName>webapp-runner.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>appassembler-maven-plugin</artifactId>
                <version>${appassembler.version}</version>
                <configuration>
                    <assembleDirectory>target</assembleDirectory>
                    <programs>
                        <program>
                            <mainClass>launch.Main</mainClass>
                            <name>webapp</name>
                        </program>
                    </programs>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>assemble</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

我的Procfile的内容是web: java %JAVA_OPTS% -cp target\classes;"target\classes\*" Main

但是当我在 heroku 中 运行 这段代码时,它给出了以下错误消息

Error: Could not find or load main class launch.Main 2016-07-20T14:22:59.864248+00:00 heroku[run.2063]: State changed from up to complete 2016-07-20T14:23:01.234275+00:00 heroku[web.1]: Process exited with status 1 2016-07-20T14:23:01.248600+00:00 heroku[web.1]: State changed from starting to crashed

但是 Main.class 在启动包中。

我该如何解决这个问题?

我在你的 pom.xmlProcfile 中看到了几个不同且相互矛盾的东西。

  • 您正在包含 webapp-运行ner,在您的 Procfile 中使用此命令可能应该是 运行:java -jar target/dependency/webapp-runner.jar yourapp.war

  • 您正在使用 appassembler-maven-plugin 构建一个可执行 JAR 文件,主要 class launch.Main

  • 您已将您的应用配置为 运行,在您的 Procfile.[=21 中使用主要 class Main(无包名称) =]

为了正确回答这个问题,我必须知道如何 运行 您的应用。您需要为我们回答这些问题:

  • 如何在本地 运行 应用程序?
  • 你的 Main class 是什么? (如果你不知道,这可能意味着你有一个 WAR 文件)。

如果您要部署 WAR 文件,则需要 运行 使用 webapp-运行ner。

如果您运行正在使用 Main class,您需要在 Profile 命令中的 java 命令中使用完全限定的 class 名称=](即 launch.Main)。