我正在将一个jar文件部署到Heroku,但是Heroku经常抱怨无法找到一个类文件(在依赖jar中)。我已经在我的jar中包含了这个类,它在本地运行时运行完美,但是当我在Heroku上运行它时,它会发出错误:
2016-06-13T06:04:30.743345+00:00 app[web.1]: Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException
2016-06-13T06:04:30.743349+00:00 app[web.1]: at java.lang.Class.getDeclaredMethods0(Native Method)
2016-06-13T06:04:30.744920+00:00 app[web.1]: at java.lang.Class.getMethod0(Class.java:3018)
2016-06-13T06:04:30.744922+00:00 app[web.1]: at java.lang.Class.getMethod(Class.java:1784)
2016-06-13T06:04:30.744923+00:00 app[web.1]: at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
2016-06-13T06:04:30.744926+00:00 app[web.1]: at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
2016-06-13T06:04:30.744927+00:00 app[web.1]: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
2016-06-13T06:04:30.745502+00:00 app[web.1]: at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
2016-06-13T06:04:30.745510+00:00 app[web.1]: ... 7 more
2016-06-13T06:04:31.375413+00:00 heroku[web.1]: Process exited with status 143
2016-06-13T06:04:31.774220+00:00 heroku[web.1]: Process exited with status 1
2016-06-13T06:04:31.789553+00:00 heroku[web.1]: State changed from starting to crashed
我在我的jar文件中包含了Maven依赖项以及实际的jar。在部署之前,Heroku是否要求依赖项位于其他位置?任何帮助将非常感激。感谢。
编辑:有没有人知道Heroku在哪里检查类文件?
答案 0 :(得分:0)
如果它是一个springboot应用程序,请确保您的pom标记如下所示:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
</execution>
</executions>
</plugin>