문제

There is a java webapp with an embedded tomcat 7 that is built with this instructions (Using tomcat7-maven-plugin).

this webapp is launching with a jar file like this: java -jar webapp.jar

Question: How to run a main class after launching this embedded tomcat?

도움이 되었습니까?

해결책

What you need is to setup your application's entry point. For this you need to configure your main class inside the jar's Manifest file.

Something like

Manifest-Version: 1.0.1
Created-By: <jdk_version>
Main-Class: fully.qalified.class.name.with.main.method

For more details on Manifest, take a look into this link here

For making this step part of your maven build cycle, you need to make some changes in the mave.jar.plugin. Something like

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
  <archive>
    <manifest>
    <mainClass>fully.qalified.class.name.with.main.method</mainClass>
    </manifest>
  </archive>
</configuration>
</plugin>

The final jar that is created will have your main method as the applications entry point

다른 팁

If I understood your question correctly. In Eclipse, Right click the project and pick "Run on Server."

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top