我正在尝试将我的Heroku应用程序拆分为一个Web进程和另一个可以在一次性dyno上运行的非Web进程。
我的目录看起来像这样:
app/
pom.xml
src/
main/
java/
Main.java
这是我的pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>app</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<assembleDirectory>target</assembleDirectory>
<useWildcardClassPath>true</useWildcardClassPath>
<programs>
<program>
<mainClass>Main</mainClass>
<name>oneoff</name>
</program>
</programs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</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.34.0</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
在我mvn package
之后,所有内容都尝试运行sh target/bin/oneoff
,它说
Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly= true -Djava.rmi.server.useCodebaseOnly=true
Error: Could not find or load main class Main.
我在Windows bash和Heroku上本地都收到此错误。但是,当我在Windows上使用批处理副本target\bin\oneoff.bat
时,它可以正常工作。
我甚至尝试通过java -cp target/classes:target/dependency/* Main
和heroku run
在本地进行{{1}}并在本地运行,导致同样的错误。