我有一个现有的应用程序,它是一个用Java编写并用maven管理的jetty应用程序。有一些基本任务可以在浏览器上运行,但主要是在从命令行(或Jenkins)运行时,它一次运行所有任务。
它通过调用特定的Maven配置文件来做到这一点。
所以maven命令行调用是
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>客户端类中有一个主过程。
public static void main(String... args) throws Exception { ...本质上
org.eclipse.jetty.server.Server对象org.springframework.http.client.ClientHttpRequest对象来激发多个任务,使用的代码如下
ClientHttpRequest .getRequestFactory() .createRequest(新URI("http://localhost:8080/tool/spring/“+ jobName),HttpMethod.GET);ClientHttpResponse clientHttpResponse = request.execute();if (clientHttpResponse.getStatusCode().value() = HttpStatus.OK_200) {抛出新URI(.);}由于各种原因,我现在要重构这个应用程序。我的目标是保持当前的设计,虽然它的主要使用点更多的控制台应用程序,我想增加一些更有用的交互功能。
为了达到目的,我已经开始重新编写这个应用程序作为Spring应用程序。我仍然希望能够从命令行(和Jenkins)中启动我想要的工作。对于Spring & Maven,有没有一种简单的(&等效的)方法来做到这一点?我正在使用Main来启动这个应用程序,所以我可能需要在这里输入一个开关。
public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootStartUpConfig.class, args);
}我猜想很多当前用于启动服务器的代码可以被转储,但我很难找到实现这一目标的最佳方法?(我更喜欢使用Maven,因为这是我们正在使用的核心工具,但如果这是更好的工具,我可以使用Gradle )。
发布于 2017-07-20 09:16:04
https://stackoverflow.com/questions/45210156
复制相似问题