仅当 运行 一个插件时才在类路径中的依赖项
a dependency to be in classpath only if run a plugin
为了开发,我 运行 通过 maven (jetty-maven-plugin) 使用 jetty 的应用程序以及我使用的所有其他部署 tomcat,
如果我 运行 我的应用程序使用 jetty maven 插件,我想将 jetty web-socket(javax-websocket-server-impl) 库添加到 class 路径,在 tomcat 这些是内置的所以我不需要告诉 maven 获取这些库。
所以为了限制这些库只用于 jetty maven 插件,我在里面添加了这些库
jetty-maven-插件
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<webAppConfig>
<contextPath>/myproject</contextPath>
</webAppConfig>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server-impl</artifactId>
<version>9.1.0.v20131115</version>
</dependency>
</dependencies>
</plugin>
只有当我 运行 插件时,这才应该将 jetty websocket 库添加到 class 路径,但它不是,而且我一直找不到 class,如果我将它添加到它工作的 pom 中的主要依赖项,但我不能这样做,因为当部署在 tomcat 中时,我不想在我的部署文件中使用 jetty 库,请纠正我,告诉我如何将这些库限制为仅执行这个插件的。
该依赖项仅可用于插件执行,不适用于应用程序。来自 pom plugin documentation:
dependencies: Dependencies are seen a lot within the POM, and are an element under all plugins element blocks. The dependencies have the same structure and function as under that base build. The major difference in this case is that instead of applying as dependencies of the project, they now apply as dependencies of the plugin that they are under. The power of this is to alter the dependency list of a plugin, perhaps by removing an unused runtime dependency via exclusions, or by altering the version of a required dpendency.
您可以使用 profiles 代替,在开发机器上 运行 时将依赖添加到 class 路径依赖。
为了开发,我 运行 通过 maven (jetty-maven-plugin) 使用 jetty 的应用程序以及我使用的所有其他部署 tomcat, 如果我 运行 我的应用程序使用 jetty maven 插件,我想将 jetty web-socket(javax-websocket-server-impl) 库添加到 class 路径,在 tomcat 这些是内置的所以我不需要告诉 maven 获取这些库。
所以为了限制这些库只用于 jetty maven 插件,我在里面添加了这些库 jetty-maven-插件
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<webAppConfig>
<contextPath>/myproject</contextPath>
</webAppConfig>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server-impl</artifactId>
<version>9.1.0.v20131115</version>
</dependency>
</dependencies>
</plugin>
只有当我 运行 插件时,这才应该将 jetty websocket 库添加到 class 路径,但它不是,而且我一直找不到 class,如果我将它添加到它工作的 pom 中的主要依赖项,但我不能这样做,因为当部署在 tomcat 中时,我不想在我的部署文件中使用 jetty 库,请纠正我,告诉我如何将这些库限制为仅执行这个插件的。
该依赖项仅可用于插件执行,不适用于应用程序。来自 pom plugin documentation:
dependencies: Dependencies are seen a lot within the POM, and are an element under all plugins element blocks. The dependencies have the same structure and function as under that base build. The major difference in this case is that instead of applying as dependencies of the project, they now apply as dependencies of the plugin that they are under. The power of this is to alter the dependency list of a plugin, perhaps by removing an unused runtime dependency via exclusions, or by altering the version of a required dpendency.
您可以使用 profiles 代替,在开发机器上 运行 时将依赖添加到 class 路径依赖。