deploying java war to heroku ,pom.xml error

放肆的年华 提交于 2019-12-06 09:04:11
Ego1

I also had a similar problem.

After head banging for 2 days, I drilled down to the error in my pom. It has nothing to do with the <build> section.

My problem was that the metadata in pom.xml had an extra <packaging>war</packaging> tag.

I modified the metadata to

        <modelVersion>4.0.0</modelVersion>
        <groupId>com.my.apps</groupId>
        <artifactId>DummyHerokuApp</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>Dummy name</name>
        <description>Dummy war</description>
        <url>http://maven.apache.org</url>

and everything is running smoothly.

I hope this helps you guys.

If you run into this problem again, try to rebuild your pom.xml based on what has been provided on heroku devcenter and then add dependencies or whatever incrementally.

According to your pom.xml file you use appasssembler-maven-plugin which generates script for running java appliction. Try to use it. Example
Something like:

Compile: 
mvn package appassembler:assemble

Run:
target/appassembler/bin/app.bat

I would recommend to use jcabi-heroku-maven-plugin, which does all this work for you automatically. All you need to do is to configure which artifact you want to run and how to run it there:

  <plugin>
    <groupId>com.jcabi</groupId>
    <artifactId>jcabi-heroku-maven-plugin</artifactId>
    <version>0.4.1</version>
    <configuration>
      <name>my-test-app</name>
      <artifacts>
        <artifact>com.example:example-app:jar::${project.version}</artifact>
      </artifacts>
      <procfile>web: java -Xmx256m -jar ./example-app.jar \${PORT}</procfile>
    </configuration>
    <executions>
      <execution>
        <goals>
          <goal>deploy</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

That's all you need to configure in pom.xml.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!