🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 20.5.1 运行远程客户端应用 远程客户端应用程序(remote client application)需要在IDE中运行,你需要使用跟将要连接的远程应用相同的classpath运行`org.springframework.boot.devtools.RemoteSpringApplication`,传参为你要连接的远程应用URL。例如,你正在使用Eclipse或STS,并有一个部署到Cloud Foundry的`my-app`工程,远程连接该应用需要做以下操作: * 从`Run`菜单选择`Run Configurations…`。 * 创建一个新的`Java Application`启动配置(launch configuration)。 * 浏览`my-app`工程。 * 将`org.springframework.boot.devtools.RemoteSpringApplication`作为main类。 * 将`https://myapp.cfapps.io`作为参数传递给`RemoteSpringApplication`(或其他任何远程URL)。 运行中的远程客户端看起来如下: ```text . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ ___ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | | _ \___ _ __ ___| |_ ___ \ \ \ \ \\/ ___)| |_)| | | | | || (_| []::::::[] / -_) ' \/ _ \ _/ -_) ) ) ) ) ' |____| .__|_| |_|_| |_\__, | |_|_\___|_|_|_\___/\__\___|/ / / / =========|_|==============|___/===================================/_/_/_/ :: Spring Boot Remote :: 1.4.1.RELEASE 2015-06-10 18:25:06.632 INFO 14938 --- [ main] o.s.b.devtools.RemoteSpringApplication : Starting RemoteSpringApplication on pwmbp with PID 14938 (/Users/pwebb/projects/spring-boot/code/spring-boot-devtools/target/classes started by pwebb in /Users/pwebb/projects/spring-boot/code/spring-boot-samples/spring-boot-sample-devtools) 2015-06-10 18:25:06.671 INFO 14938 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@2a17b7b6: startup date [Wed Jun 10 18:25:06 PDT 2015]; root of context hierarchy 2015-06-10 18:25:07.043 WARN 14938 --- [ main] o.s.b.d.r.c.RemoteClientConfiguration : The connection to http://localhost:8080 is insecure. You should use a URL starting with 'https://'. 2015-06-10 18:25:07.074 INFO 14938 --- [ main] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 2015-06-10 18:25:07.130 INFO 14938 --- [ main] o.s.b.devtools.RemoteSpringApplication : Started RemoteSpringApplication in 0.74 seconds (JVM running for 1.105) ``` **注** 因为远程客户端使用的classpath跟真实应用相同,所以它能直接读取应用配置,这就是`spring.devtools.remote.secret`如何被读取和传递给服务器做验证的。 强烈建议使用`https://`作为连接协议,这样传输通道是加密的,密码也不会被截获。 如果需要使用代理连接远程应用,你需要配置`spring.devtools.remote.proxy.host`和`spring.devtools.remote.proxy.port`属性。