通常我用命令运行我的Spring Boot应用程序:
mvn spring-boot:run -Drun.arguments=--server.port=9090 \
-Dpath.to.config.dir=/var/data/my/config/dir
Run Code Online (Sandbox Code Playgroud)
我想设置自定义端口进行调试,所以我可以从eclipse连接.当我从示例http://docs.spring.io/spring-boot/docs/1.1.2.BUILD-SNAPSHOT/maven-plugin/examples/run-debug.html添加参数时
mvn spring-boot:run -Drun.arguments=--server.port=9090 \
-Dpath.to.config.dir=/var/data/my/config/dir \
-Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8787"
Run Code Online (Sandbox Code Playgroud)
它有效,但其他论点喜欢server.port或path.to.config.dir不再被认可,我得到例外:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed
to parse configuration class [com.my.app.Controller]; nested exception
is java.lang.IllegalArgumentException: Could not resolve placeholder
'path.to.config.dir' in string value
file:///${path.to.config.dir}/some.properties"
Run Code Online (Sandbox Code Playgroud)
问题:如何运行所有参数?
我正在使用maven和java-9构建我的项目.我在我的pom.xml文件中添加了:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<arg>--add-modules</arg>
<arg>java.xml.bind</arg>
</compilerArgs>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但是,为了运行应用程序,我必须像这样运行它:
java -jar --add-modules java.xml.bind my-app.jar
Run Code Online (Sandbox Code Playgroud)
有没有办法构建应用程序,从命令行运行而不是--add-modules java.xml.bindjava命令行参数?