使用maven-spring-boot-plugin将类路径添加到SpringBoot命令行开始 [英] Adding classpath to SpringBoot command line start when using maven-spring-boot-plugin
问题描述
我正在尝试在运行Spring Boot应用程序时添加一个类路径,该应用程序使用以下命令运行
I'm trying to add a classpath to when I run my spring boot application, which is run with the following command
mvn spring-boot:run
我目前能够使用插入字段中的自定义参数将classpath文件夹添加到我的maven测试中
I'm currently able to add a classpath folder to my maven tests, using custom arguments which inserted into the field
但是,这种方法不适用于通过以下方式运行应用程序 mvn spring-boot:run
However this approach has not worked for running the application with mvn spring-boot:run
推荐答案
The Spring Boot Maven Plugin spawns a JVM which will, by default, include whatever your project says should be on the classpath e.g.
-
${project.build.outputDirectory}
这包括类和资源
在项目的POM中声明的 - 依赖项
${project.build.outputDirectory}
this includes classes and resources- dependencies declared in your project's POM
如果您需要向此类路径添加内容,则插件提供以下内容:
If you need to add things to this classpath, the plugin offers the following:
- addResources
- folders
- useTestClasspath
例如,如果要将此文件夹:/this/that/theother
添加到类路径,则可以按以下方式配置spring-boot插件:
For example, if you want to add this folder: /this/that/theother
to the classpath then you would configure the spring-boot plugin as follows:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<folders>
<folder>
/this/that/theother
</folder>
</folders>
</configuration>
</plugin>
有了该配置,如果调用mvn spring-boot:run -X
,您会看到附加文件夹包含在类路径的前面...
With that configuration in place, if you invoke mvn spring-boot:run -X
you'll see that the additional folder is included on the front of the classpath ...
[DEBUG]分叉进程的类路径:/this/that/theother:...
[DEBUG] Classpath for forked process: /this/that/theother:...
这篇关于使用maven-spring-boot-plugin将类路径添加到SpringBoot命令行开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!