是否可以仅通过命令行来使用指定的war
文件和上下文路径运行jetty
?
类似于以下命令:
java -jar $jettyHome/start.jar -Dwar.location=myApp.war -DcontextPath=/myApp OPTIONS=default,plus,jsp
使用 jetty runner。
java -jar jetty-runner.jar my.war
使用Maven,您可以通过将以下内容添加到pom.xml
文件来进行安装:
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>copy</goal></goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-runner</artifactId>
<version>7.5.4.v20111024</version>
<destFileName>jetty-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
运行:
mvn package
并且使用方式如下:
java -jar target/dependency/jetty-runner.jar target/*.war
http://www.eclipse.org/jetty/documentation/current/runner.html
http://central.maven.org/maven2/org/eclipse/jetty/jetty-runner/
java.lang.NoClassDefFoundError: org/apache/tomcat/util/IntrospectionUtils
错误。这是否相关? - zygimantusmvn archetype:generate \
-DarchetypeGroupId=org.duelengine \
-DarchetypeArtifactId=war-bootstrap-archetype \
-DarchetypeVersion=0.2.1
java -jar bootstrap.jar -war myapp.war -p 8080 -c /myapp --jetty
从命令行安装Maven:
sudo apt install maven
在存放pom.xml的文件夹中,通过命令行运行war包:
mvn jetty:run-war
$ git clone https://github.com/kissaten/jetty-runner-minimal
$ cd jetty-runner-minimal
$ mvn package
$ wget https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war
$ java -jar target/dependency/jetty-runner.jar sample.war
如果您有适当的起始配置(jetty.xml)设置,那么这是可能的。
直接使用Jetty不会附带一个能够实现此功能的jetty.xml文件,但是您可以很容易地编写一个。
这意味着您需要进行以下操作之一:
Have a command line that was more like
java -jar $jettyHome/start.jar -Dwar.location=myApp.war -DcontextPath=/myApp jetty-myapp.xml
or
java -jar $jettyHome/start.jar -Dwar.location=myApp.war -DcontextPath=/myApp etc/jetty.xml etc/jetty-plus.xml jetty-deploy-app.xml
Override the etc/jetty.xml yourself and put the info you want in there.
Jetty启动非常简单,实际上只需要生成一个XML文件以达到所需的效果。该XML文件可以从系统属性中读取值,因此您可以使用各种“-D”选项。