2

我正在测试 Codenvy ( https://codenvy.io ) 并制作了一个非常简单的 Spring Boot Web 控制器:

@Controller
@EnableAutoConfiguration
public class SampleController { 

@RequestMapping("/")
@ResponseBody
String home() {
    return "Hello World!";
}

public static void main(String[] args) throws Exception {
    SpringApplication.run(SampleController.class, args);
}

}

Pom.xml:

 <parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>1.4.2.RELEASE</version>
 </parent>
 <dependencies>
 <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
  </dependency>

启动正常:

          2016-11-17 22:34:23.060  INFO 344 --- [           main] sample.SampleController                  : Starting SampleController on 780c1f85387b with PID 344 (/projects/Spring-boot started by user in /projects/Spring-boot)
      2016-11-17 22:34:23.084  INFO 344 --- [           main] sample.SampleController                  : No active profile set, falling back to default profiles: default
      2016-11-17 22:34:23.334  INFO 344 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@70e8f8e: startup date [Thu Nov 17 22:34:23 UTC 2016]; root of context hierarchy
      2016-11-17 22:34:34.172  INFO 344 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
      2016-11-17 22:34:34.343  INFO 344 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
      2016-11-17 22:34:34.358  INFO 344 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.6
      2016-11-17 22:34:34.746  INFO 344 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
      2016-11-17 22:34:34.748  INFO 344 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 11431 ms
      2016-11-17 22:34:35.782  INFO 344 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
      2016-11-17 22:34:35.808  INFO 344 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
      2016-11-17 22:34:35.810  INFO 344 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
      2016-11-17 22:34:35.812  INFO 344 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
      2016-11-17 22:34:35.814  INFO 344 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
      2016-11-17 22:34:37.532  INFO 344 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@70e8f8e: startup date [Thu Nov 17 22:34:23 UTC 2016]; root of context hierarchy
      2016-11-17 22:34:38.123  INFO 344 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto java.lang.String sample.SampleController.home()
      2016-11-17 22:34:38.170  INFO 344 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
      2016-11-17 22:34:38.170  INFO 344 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
      2016-11-17 22:34:38.490  INFO 344 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
      2016-11-17 22:34:38.490  INFO 344 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
      2016-11-17 22:34:38.646  INFO 344 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
      2016-11-17 22:34:39.377  INFO 344 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
      2016-11-17 22:34:39.669  INFO 344 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
      2016-11-17 22:34:39.708  INFO 344 --- [           main] sample.SampleController                  : Started SampleController in 20.214 seconds (JVM running for 21.802)

在我的浏览器中,该项目的网址是:https ://codenvy.io/dashboard/#/ide/tyvain/BOTS

简单(愚蠢)的问题:我如何调用这个 URL 来测试它?

4

2 回答 2

2

这不是一个愚蠢的问题:)

当您在云 IDE 中时,应用程序正在另一个运行时内运行。在 codenvy 的情况下,我们使用 Docker 容器作为运行时。Docker 允许您启动应用程序,但随后使用临时端口范围获取服务器的内部端口号并使其可供外部世界使用。它将端口映射到从 32765+ 范围开始的另一个数字。这样做是因为如果两个工作区中有两台服务器在同一个端口上运行,它们都会相互冲突,因此 docker 将端口置于此范围内以避免端口冲突。

您需要设置一个带有 previewURL 的命令,该命令将在您运行它时向您显示服务器的 URL。我们在 www.eclipse.org 上有很多关于如何生成预览 URL 的文档。而且,您还可以查看示例中命令的结构(尝试 maven spring 示例)。

于 2016-11-17T23:08:24.800 回答
-1

https://codenvy.com/docs/user-guide/previews/index.html

这是您要问的,正在寻找的吗?

看起来变量是运行命令的命令调色板的一部分

于 2017-08-28T22:48:27.730 回答