简体   繁体   中英

How to deploy a war in a jetty embedded server running into an executable jar?

I want to deploy a war file, let's call it app.war, onto an embedded jetty.

So the simpliest code for that is:

new WebAppContext(server, path, "/");

where path is eventually something like "./dist/app.war". And it works like a charm when running from Eclipse, but things get worse when I want to do the same thing from a runnable jar of my project.

Even if the jar architecture is good :

  • META-INF
  • dist
    • app.war
  • ...

The file is not found. I know standard paths are not consistent in running jar files but trying with "jar:file:.../project.jar!/dist/app.jar" doen't do better. Is there any solution for this issue ? Thank you !

i will use uber plugin to make executable jar. with maven you can simply add

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <finalName>uber-${artifactId}-${version}</finalName>
            </configuration>
        </plugin>

check here http://maven.apache.org/plugins/maven-shade-plugin/ this will create fully self-contained jar with all resources, classes and dependencies

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM