丹阳做网站的,微网站开发平台系统软件,培训机构哪家最好,聚美联盟网站怎么做standalone应用我之前在博客中写过一种编写独立的Spring Integration应用程序的方法。 Spring Boot使创建此独立应用程序变得更加简单。 简单的流程是轮询USGS服务#xff0c;以提供有关世界各地地震活动的信息并记录该信息。 使用Spring Integration描述的流程如下#xf… standalone应用 我之前在博客中写过一种编写独立的Spring Integration应用程序的方法。 Spring Boot使创建此独立应用程序变得更加简单。 简单的流程是轮询USGS服务以提供有关世界各地地震活动的信息并记录该信息。 使用Spring Integration描述的流程如下 int:inbound-channel-adapter channelquakeinfotrigger.channel expressionint:poller fixed-delay60000/int:poller/int:inbound-channel-adapterint:channel idquakeinfo.channelint:queue capacity10//int:channelint:channel idquakeinfotrigger.channel/int:channel int-http:outbound-gateway idquakerHttpGatewayrequest-channelquakeinfotrigger.channelurlhttp://earthquake.usgs.gov/earthquakes/feed/geojson/all/hourhttp-methodGETexpected-response-typejava.lang.StringcharsetUTF-8reply-timeout5000reply-channelquakeinfo.channel /int-http:outbound-gatewayint:logging-channel-adapter idmessageLogger log-full-messagetrue channelquakeinfo.channel levelERRORint:poller fixed-delay5000 /int:poller/int:logging-channel-adapter 在预引导过程中编写主程序以启动此流程的方式应遵循以下原则 package standalone;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class Main {public static void main(String[] args) {ClassPathXmlApplicationContext applicationContext new ClassPathXmlApplicationContext(classpath:/httpgateway.xml);applicationContext.registerShutdownHook();}
} 但是使用Spring-boot恕我直言配置更简单 package standalone;import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;Configuration
ImportResource(classpath:httpgateway.xml)
public class Main {public static void main(String[] args) {SpringApplication.run(Main.class, args);}
} 并通过此更改以及spring-boot-maven-plugin插件可以通过以下方式启动应用程序 mvn spring-boot:run 我有一个非常小手在通过促进变化的插件来启动应用程序而无需手动首先运行编译步骤解决这个启动脚本。 甚至更好的是spring-boot-maven-plugin提供了将整个应用程序打包到可执行jar中的工具该jar在打包阶段会被触发如遮阳插件所示 mvn package 可执行的jar运行如下 java -jar target/si-standalone-sample-1.0-SNAPSHOT.jar 可以在此github位置获得具有此更改的更新项目– https://github.com/bijukunjummen/si-standalone-sample 参考 all和其他博客中来自JCG合作伙伴 Biju Kunjummen的带有Spring Boot的Spring Integration Standalone应用程序 。 翻译自: https://www.javacodegeeks.com/2014/02/spring-integration-standalone-application-with-spring-boot.htmlstandalone应用