【发布时间】:2016-06-20 04:51:05
【问题描述】:
这是我的课
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Configuration
@ComponentScan
@EnableAutoConfiguration
@SpringBootApplication
public class TomcatIcınApplication {
public static void main(String[] args) {
SpringApplication.run(TomcatIcınApplication.class, args);
}
}
@RestController
class GreetingController {
@RequestMapping("/hello/hi")
String hello( ) {
return "Hello, xx!";
}
}
当我运行应用程序并打开localhost:8080/hello/hi 时,我可以看到输出。但是从Edit Configurations开始,当我将端口8081上的tomcat服务器添加为localhost:8081/hello并这次运行tomcat时,它会调用应用程序并打开页面但它是空的。
为什么我看不到我的输出?
【问题讨论】:
-
我认为你需要访问这个 url-localhost:8081/ProjectName/hello/hi 其中项目名称是你在 Tomcat 中部署的战争文件名。
标签: java spring tomcat intellij-idea spring-boot