启动弹簧防尘套&;使用maven配置文件拨打电话
我有一个现有的应用程序,它是一个用Java编写并用maven管理的jetty应用程序。有几个基本任务可以从浏览器运行,但主要是从命令行(或Jenkins)运行时,它可以一次性运行所有任务 它通过调用特定的Maven概要文件来实现这一点 因此,maven命令行调用是启动弹簧防尘套&;使用maven配置文件拨打电话,maven,spring-boot,Maven,Spring Boot,我有一个现有的应用程序,它是一个用Java编写并用maven管理的jetty应用程序。有几个基本任务可以从浏览器运行,但主要是从命令行(或Jenkins)运行时,它可以一次性运行所有任务 它通过调用特定的Maven概要文件来实现这一点 因此,maven命令行调用是 mvn clean install -P autorun 自动运行配置文件是 <profile> <id>autorun</id> <build>
mvn clean install -P autorun
自动运行配置文件是
<profile>
<id>autorun</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<java classname="com.app.tool.Client" >
<arg value="-h" />
<classpath>
<pathelement path="${runtime_classpath}"/>
</classpath>
</java>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
本质上
org.eclipse.jetty.server.server
对象org.springframework.http.client.ClientHttpRequest
对象,使用代码按照
ClientHttpRequest request = restTemplate
.getRequestFactory()
.createRequest(
new URI("http://localhost:8080/tool/spring/" + jobName),
HttpMethod.GET);
ClientHttpResponse clientHttpResponse = request.execute();
if (clientHttpResponse.getStatusCode().value() != HttpStatus.OK_200) {
throw new RuntimeException(...);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootStartUpConfig.class, args);
}
我猜目前用于启动服务器的很多代码都可能被转储,但我正在努力找到实现这一点的最佳方法?(我更喜欢使用Maven,因为这是我们正在使用的核心工具,但如果Gradle更擅长的话,我可以使用它)。要从命令行运行spring boot应用程序,您可以包括spring boot Maven插件,请参阅此处的参考 然后使用从命令行启动它
mvn spring-boot:run
要从命令行运行SpringBoot应用程序,可以包括SpringBootMaven插件,请参见此处的参考 然后使用从命令行启动它
mvn spring-boot:run
为什么发出请求会有所不同?使用maven时,您可以使用
mvn springBoot:run
来启动应用程序,而不是使用配置文件或其他任何东西。为什么发出请求会有所不同?使用maven时,您可以使用mvn springBoot:run
来启动应用程序,而不是使用配置文件或其他任何东西。哦,是的,实际上我已经在这样做了,我想这个答案(与您的答案结合起来)让我达到了我想要的目的。对不起,现在觉得有点傻@Gringgordo:我建议您查看spring配置文件以创建配置文件,然后您可以在应用程序中启动时传入配置文件名称,而不是将所有内容作为命令行参数传递。不是很确定你需要这个,但是看看哦,是的,实际上我已经在做了,我想这个答案(加上你的)让我达到了我想要的目的。对不起,现在觉得有点傻@Gringgordo:我建议您查看spring配置文件以创建配置文件,然后您可以在应用程序中启动时传入配置文件名称,而不是将所有内容作为命令行参数传递。不是很确定你需要这个,但是看看