Я создаю свое первое приложение Spring Boot. Но я не могу получить правильный ответ контроллера requestMapping.
Это мой основной класс:
package com.hello.world;
@SpringBootApplication
public class HelloWorld implements CommandLineRunner{
public static void main(String[] args) {
SpringApplication.run(HelloWorld.class, args);
}
@Override
public void run(String... args) throws Exception {
....
}
}
А это мой RestController:
package com.hello.world.controllers;
@RestController
public class UrlMappingControllers {
@RequestMapping("/hi")
String home() {
return "Hello World!";
}
}
Если я взгляну на журнал, я увижу сопоставление «/ привет»:
restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hi]}" onto java.lang.String com.hello.world.controllers.UrlMappingControllers.home()
Но когда я обращаюсь к: http:localhost:8080/hi, я получаю пустую страницу, я ожидал увидеть текст «Hello World».
Почему я получаю пустую страницу?
--- Редактировать ----
Я только что понял, что получаю пустую страницу только тогда, когда добавляю службу cxf. Я думаю, это потому, что аннотация @configuration для этого класса:
package com.hello.world.helloWorld.configuration;
@Configuration
public class CXFConfiguration {
@Bean
public ServletRegistrationBean dispatcherServlet() {
return new ServletRegistrationBean(new CXFServlet(), "/services/*");
}
@Bean(name=Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {
SpringBus springBus = new SpringBus();
return springBus;
}
@Bean
public Endpoint endpointGreentingService() {
EndpointImpl endpoint = new EndpointImpl(springBus(), new GreetingServiceImpl());
endpoint.getFeatures().add(new LoggingFeature());
endpoint.publish("/GreetingService");
return endpoint;
}
}
Может ли это быть связано?