我试图评估码头的快速发展或项目,目前正在运行的tomcat。我的配置看起来
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.3.v20140905</version>
<configuration>
<scanIntervalSeconds>3</scanIntervalSeconds>
<webApp>
<descriptor>${project.build.directory}/${project.build.finalName}/WEB-INF/web.xml</descriptor>
<resourceBases>
<directory>${basedir}/src/main/webapp</directory>
<directory>${basedir}/../SharedWeb/src/main/webapp</directory>
</resourceBases>
<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
<contextPath>/test</contextPath>
</webApp>
</configuration>
</plugin>我有主要的战争依赖于SharedWeb战争通过战争覆盖机制。我为两个maven项目指定了resourceBases,这样资源的更改就会被自动扫描并动态地重新加载,并且所有的更改都可以正常工作。另外,当我在主war中编译类时,jetty会自动重新启动,重新加载最新的更改。但是,当我试图更改SharedWeb项目中的任何类并编译它时,类都不会被重新加载。我只是想知道是否有一种方法可以使嵌入jetty自动从SharedWeb重新加载类?我理解jetty插件使用本地maven存储库中的SharedWeb war,所以在看到任何更改之前,我需要安装SharedWeb工件。所以我没有很高的期望,但也许我错过了什么。
发布于 2014-10-02 01:12:22
伊凡
插件使用的是来自依赖战的类和资源,而不是添加的类和资源。简单地告诉jetty观察该位置,并在其中发生变化时重新部署--它不会将其放到类路径上。
您需要告诉jetty使用依赖war项目中的类和资源,而不是war工件。
所以做些类似的事情:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.3.v20140905</version>
<configuration>
<webApp>
<!-- tell jetty to use the classes from the dependency
webapp project directly -->
<extraClassPath>${basedir}/../SharedWeb/target/classes</extraClassPath>
<!-- tell jetty to use both this project's static
resources, and those of the dependency webapp project -->
<resourceBases>
<directory>${basedir}/src/main/webapp</directory>
<directory>${basedir}/../SharedWeb/src/main/webapp</directory>
</resourceBases>
</webApp>
<scanIntervalSeconds>3</scanIntervalSeconds>
<!-- tell jetty to watch the dependency webapp project classes
dir for changes -->
<scanTargets>
<scanTarget>${basedir}/../SharedWeb/target/classes/</scanTarget>
</scanTargets>
</configuration>
</plugin>1月
发布于 2014-10-01 21:22:34
由于似乎没有一个对这个问题足够具体的好的事先回答(又名<scanTarget>__),所以我将发布这个新的答案,并修改标题以使将来更容易找到。
您正在寻找的是<scanTarget>,因为这将允许您自定义将触发热重新部署的更改内容的扫描位置。
jetty-maven-plugin故意不为自定义<resourceBases>设置这个插件,因为在许多合法的用例中,这会导致侵略性/过于频繁/或无限重部署。人们决定,最好打破<scanTarget>条目的“约定而不是配置”,让开发人员决定应该扫描哪些内容以进行更改。
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.3.v20140905</version>
<configuration>
...
<scanIntervalSeconds>3</scanIntervalSeconds>
<scanTargets>
<scanTarget>${basedir}/../SharedWeb/src/main/webapp/</scanTarget>
<scanTarget>${basedir}/../SharedWeb/target/classes/</scanTarget>
</scanTargets>
</configuration>
</plugin>https://stackoverflow.com/questions/26150681
复制相似问题