Home » Java » How can I make an executable jar with the wepapp configuration of Eclipse in it

How can I make an executable jar with the wepapp configuration of Eclipse in it

Posted by: admin July 23, 2018 Leave a comment

Questions:

I am making a java web application in Eclipse with the use of Maven.
I am now trying to build this webapp with maven.
At the end of the build process I would like to have the webapp(together with its dependencies) packaged in an executable jar with an embedded Tomcat8 in it.

So that I just can run it on a local pc like this: java -jar MyWebApp.jar

My project structure in Eclipse is as follows(standard wepapp structure):

|– pom.xml
|-- src
|-- main
| |-- java
| |-- resources
| |
— webapp

I am using the maven-assembly-plugin to try and accomplish this.

But my problem is this:
While developing, I am testing this project in a configured tomcat8 server in Eclipse.
So under the “webapp” folder in Eclipse there is a web.xml and also a server.xml where our project is configured in(connectors, servlets, …)

My question is now:
Can I get those wepapp configuration files from Eclipse (server.xml, web.xml, …) being packaged in the executable jar? So that when I run the jar, these configuration files will be used to start the embedded Tomcat in it.

And also, is it possible to get this done with the maven-assembly-plugin?

Thanks

Answers: