2016-07-20 5 views
0

다음 내 pom.xml 파일입니다Heroku가 실현 할 수 없습니다 메인 클래스

<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는 시작 패키지에 있습니다.

어떻게 정렬 할 수 있습니까?

답변

1

pom.xmlProcfile에 여러 가지 상충되는 내용이 있습니다. 당신은 아마 당신의 Procfile에서이 명령을 실행해야합니다 웹 애플리케이션 주자 포함되어

  • : 당신은 실행 JAR 파일을 작성하는 appassembler-maven-plugin를 사용하는 java -jar target/dependency/webapp-runner.jar yourapp.war

  • , 메인 클래스와 launch.Main

  • Procfile에 메인 클래스 Main (패키지 이름 없음)으로 실행되도록 앱을 구성했습니다.

질문에 올바르게 대답하려면 앱을 실행하는 방법을 알아야합니다. Google에 다음 질문에 답변해야합니다.

  • 어떻게 로컬에서 응용 프로그램을 실행합니까?
  • Main 클래스 란 무엇입니까? (모르는 경우에는 WAR 파일이 있음을 의미합니다).

WAR 파일을 배포하는 경우 webapp-runner로 실행해야합니다.

메인 클래스를 실행하는 경우 Profile에있는 java 명령 (예 : launch.Main)의 정규화 된 클래스 이름을 사용해야합니다.

관련 문제