1

我正在使用命令 mvn jetty:run 使用 jetty 插件使用 maven 运行 jetty。

是否有命令行选项可以将外部目录添加到类路径?类似于 java -cp 选项的东西?

TIA

4

3 回答 3

2

如果为 定义 Maven 属性extraClasspath,则可以使用命令行系统属性传递自定义的 extraClasspath 值。例如,如果您是 POM,则具有以下内容:

<properties>
  <jetty.extraClasspath />
</properties>

...

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.4.14.v20181114</version>
  <configuration>
    <webApp>
      <extraClasspath>${jetty.extraClasspath}</extraClasspath>
    </webApp>
  </configuration>
</plugin>

您可以使用mvn jetty:run -Djetty.extraClasspath=../resources/.

于 2019-02-19T17:39:01.170 回答
1

您是否尝试过此处建议的解决方案:

将类路径添加到在 Maven 集成测试中运行的码头

<webAppConfig>
  <contextPath>/nportal</contextPath>
  <!-- All I want to do here is add in the /etc/jetty/classes for runtime files. For some reason I have to also add back in the /target/classes directory -->
  <extraClasspath>${basedir}/target/classes/;${basedir}/etc/jetty/classes/</extraClasspath>
</webAppConfig> 
于 2011-11-08T17:13:30.350 回答
0

从打印的mvn jetty:help -Ddetail=true -Dgoal=run内容来看,从命令行看来是不可能的

于 2015-04-24T08:10:56.023 回答