如何设置Jetty的VM参数从maven-jetty-plugin运行?
例如,我需要通过命令将-Xmx
参数传递给Jetty mvn jetty:run
.
我正在尝试将Maven WAR项目拆分为两个模块,以便我可以使用命令行工具构建单独的JAR文件.结果具有以下结构:
pom.xml
(包装pom
,有两个模块)project-jar/
pom.xml
(包装jar
)project-war/
pom.xml
(包装war
,取决于project-jar
)如果我mvn
从root 运行命令,一切正常.我想继续使用mvn jetty:run
,但为此我需要在WAR子项目中执行命令.如果我这样做,找不到project-jar
子项目,所以它不会运行.即使mvn jetty:run-war
在target
目录中完全组装的WAR文件失败,因为它首先尝试"构建"项目.我只是通过安装project-jar
到本地Maven存储库来设法使它工作,这不是很好.
有没有办法在多模块Maven配置中使用Jetty插件?
我正在使用s/o代码,它是由maven构建的java webapp.webapp由maven脚本运行,如下所示,应用程序在localhost:8080上运行,:
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.8.v20121106</version>
<configuration>
<contextPath>/</contextPath>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<!--<port>8085</port>-->
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<stopKey>stop</stopKey>
<stopPort>8089</stopPort>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
我想附加IntelliJ的调试器,以便我可以单步执行代码.我尝试设置一个调试器配置,如:Jetty Server,然后是'Remote',但它说没有指定Application Server.我也试过'Local',它说'主配置文件不包括'.
那么我该怎么做才能附加调试器?提前致谢.
debugging web-applications jetty intellij-idea maven-jetty-plugin
我在项目pom.xml中添加了jetty mvn插件代码.
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
<configuration>
<contextPath>/redkites</contextPath>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>deploy</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当我使用命令sudo mvn compile
和sudo mvn clean install
,我没有发现任何错误和成功建立,但是当我键入命令sudo mvn jetty:run
,我得到一个错误:
[ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/root/.m2/repository), central (http://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with …
Run Code Online (Sandbox Code Playgroud) 我是Maven的新手.我有一个多模块maven 2项目,具有以下结构(稍微简化):
Project (POM packaging)
|
+-- Module1 (JAR)
| |
| +-- src
| |
| +-- main
| |
| +-- java
| +-- resources
|
+-- Module2 (JAR)
| |
| ...
|
+-- Web Module (WAR)
|
...
Run Code Online (Sandbox Code Playgroud)
我已将Web模块配置为包含Maven Jetty插件.这非常适合构建生产工件.为了开发,我发现我需要调用mvn install
我更改的任何模块,然后停止jetty并调用jetty:再次运行.
如果有一种方法可以让插件直接从每个模块的目标目录中选择更改,那么效率会更高.根据jetty插件文档,似乎有这样的功能,但它似乎只适用于WAR模块.
对我来说更重要的是能够更改资源文件,而无需重新启动jetty.这是因为大多数资源都是HTML模板文件,在开发过程中设计和更新模板的效率极高,而无需重新启动以查看更改.
那么,有没有办法设置jetty插件的类路径,以包含每个JAR模块的目标/类和资源目录,而不是本地存储库中的实际JAR?
谢谢!
的Yaniv
我注意到在尝试设置在jetty上运行的JSF 2 webapp时,我有这个错误:
java.lang.IllegalStateException:应用程序在启动时未正确初始化,找不到Factory:javax.faces.context.FacesContextFactory
这可以通过添加到我的web.xml轻松解决
<listener>
<listener-class>
com.sun.faces.config.ConfigureListener
</listener-class>
</listener>
Run Code Online (Sandbox Code Playgroud)
我试过寻找一个详细的解释,但是徒劳无功..
jetty-maven-plugin:8.0.3.v20111011:run + jdk 7 + eclipse indigo
这是我的maven依赖:
<dependencies>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.1.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
这是我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Basic Setup Web Application</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<listener>
<listener-class>
com.sun.faces.config.ConfigureListener
</listener-class>
</listener>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
</web-app>
Run Code Online (Sandbox Code Playgroud)
这是jetty插件的输出:
[INFO] <<< jetty-maven-plugin:8.0.3.v20111011:run (default-cli) @ BasicSetup <<<
[INFO]
[INFO] --- jetty-maven-plugin:8.0.3.v20111011:run (default-cli) @ …
Run Code Online (Sandbox Code Playgroud) 我想用maven jetty插件运行我的web应用程序.但是在启动一段时间后,它会给出错误:
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
2014-08-10 17:39:45.840:INFO:oejs.Server:main: jetty-9.2.2.v20140723
2014-08-10 17:40:54.961:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.m.p.JettyWebAppContext@1e2c8{/asd,file:/C:/dev/project/hope/target/asd-1.0/,STARTING}{C:\dev\project\hope\target\asd-1.0.war}
java.lang.Exception: Timeout scanning annotations
at org.eclipse.jetty.annotations.AnnotationConfiguration.scanForAnnotations(AnnotationConfiguration.java:570)
at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:440)
at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:471)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1329)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:497)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:365)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
Run Code Online (Sandbox Code Playgroud)
我正在使用带有注释的spring mvc,我认为它存在问题.
当我尝试在eclipse jetty插件上运行它时,它会成功启动,但是使用maven插件,它会产生错误.
有任何想法吗?
我有以下Maven代码段
<plugin>
<!-- http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin -->
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.16</version>
<configuration>
<contextPath>/thomas</contextPath>
<stopPort>9966</stopPort>
<stopKey>foo</stopKey>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我想将上下文路径设置为"/"但Jetty插件不尊重它,上下文回退到使用文件夹(或可能是模块)名称作为上下文路径.如果我使用名称设置上下文路径,例如:
<contextPath>/thomas</contextPath>
Run Code Online (Sandbox Code Playgroud)
有什么建议?
提前致谢.
Jetty默认端口是8080,但我想将默认端口更改为其他端口(9999).
我阅读了一些教程,他们说几乎所有的配置信息都默认保存在文件中jetty.xml
,这个文件位于$JETTY_HOME/etc/
.然后,将属性更改jetty.port
为9999.但是,当我打开该文件时,我找不到其中的jetty.port属性jetty.xml
.我目前正在使用Jetty-9.2.1,端口是8080.
我在jetty-http.xml文件下找到了jetty.port属性.即使我在jetty-http.xml文件中将端口更改为8090,Jetty仍然在端口8080上运行.
的jetty.xml
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<!-- =============================================================== -->
<!-- Documentation of this file format can be found at: -->
<!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax -->
<!-- -->
<!-- Additional configuration files are available in $JETTY_HOME/etc -->
<!-- and can be mixed in. See start.ini file for the default -->
<!-- configuration files. -->
<!-- -->
<!-- For a description of the configuration mechanism, see the -->
<!-- output of: …
Run Code Online (Sandbox Code Playgroud) 我正在使用以下插件配置调用"jetty:run"目标:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.4.4.v20110707</version>
<configuration>
<scanIntervalSeconds>5</scanIntervalSeconds>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>80</port>
</connector>
</connectors>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
尽管我的项目将slf4j声明为依赖项,但Jetty拒绝将任何内容记录到slf4j.如果我将"-Dorg.eclipse.jetty.util.log.DEBUG = true"传递给JVM,Jetty会输出大量的日志,但它们似乎转到stderr而不是slf4j.有任何想法吗?
jetty ×8
maven ×3
maven-2 ×3
java ×2
annotations ×1
debugging ×1
jsf-2 ×1
maven-plugin ×1
servlets ×1
slf4j ×1
spring-mvc ×1