Open xiaohanfeidao opened 2 years ago
Hello, I see you have defined following in YAML file:
jersey: application-path: /jersy
This is also shown in you logging above:
2022-06-23 14:33:31.162 INFO 24620 --- [ main] o.g.grizzly.servlet.WebappContext : [application] Servlet [org.glassfish.jersey.servlet.ServletContainer] registered for url pattern(s) [[/jersy/]].
So try following path: http://localhost:8082/jersy/hello
Hey,In this way, the access also returns error
According to the wiki guidelines, I only need to distinguish the root path of spring MVC and Jersy, You can see that I have distinguished the root path between spring MVC and Jersey。
I still can't find the wrong configuration,hope to get your help,thanks。
That's the issue, as already stated:
Since version 2.6 it is possible to use the Spring REST controllers instead of the default Jersey JAX-RS implementation. To be able to do so, make sure you specify the spring.jersey.application-path property to a specific path which is different than the root (e.g. /) otherwise there will be a path conflict and requests will never be able to reach the Spring DispatcherServlet.
Try setting it to /api as I said before and see if that works, it won't work when registered to the root due to the fact how Grizzly internal works.
Hey,
I integrated grizzly starter in my project,The codes are as follows:
@SpringBootApplication public class App { public static void main( String[] args ) { SpringApplication.run(App.class, args); }
}
spring mvc controller file: import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping;
/**
@date 2022/6/23 13:08 */ @RequestMapping public class TestController {
@GetMapping("/hello") public String message() { return "Hello World"; } }
application.yml: spring: application: name: app-grizzly jersey: application-path: /jersy
server: port: 8082 servlet: context-path: /
The startup log is as follows:
2022-06-23 14:33:30.483 INFO 24620 --- [ main] b.d.b.g.config.GrizzlyAutoConfiguration : Running with Grizzly Spring Boot Starter v2.7 2022-06-23 14:33:30.683 INFO 24620 --- [ main] o.g.grizzly.servlet.WebappContext : [application] Initializing Spring embedded WebApplicationContext 2022-06-23 14:33:30.683 INFO 24620 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 902 ms 2022-06-23 14:33:30.702 WARN 24620 --- [ main] b.d.boot.grizzly.http.HttpServerFactory : java.lang.UnsupportedOperationException: Not supported yet. 2022-06-23 14:33:30.703 INFO 24620 --- [ main] o.g.grizzly.servlet.WebappContext : Starting application [application] ... 2022-06-23 14:33:31.162 INFO 24620 --- [ main] o.g.grizzly.servlet.WebappContext : [application] Servlet [org.glassfish.jersey.servlet.ServletContainer] registered for url pattern(s) [[/jersy/]]. 2022-06-23 14:33:31.164 INFO 24620 --- [ main] o.g.grizzly.servlet.WebappContext : [application] Initializing Spring DispatcherServlet 'dispatcherServlet' 2022-06-23 14:33:31.164 INFO 24620 --- [ main] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet' 2022-06-23 14:33:31.324 INFO 24620 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2022-06-23 14:33:31.379 INFO 24620 --- [ main] o.s.web.servlet.DispatcherServlet : Completed initialization in 215 ms 2022-06-23 14:33:31.379 INFO 24620 --- [ main] o.g.grizzly.servlet.WebappContext : [application] Servlet [org.springframework.web.servlet.DispatcherServlet] registered for url pattern(s) [[/]]. 2022-06-23 14:33:31.380 INFO 24620 --- [ main] o.g.grizzly.servlet.WebappContext : [application] Filter [org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter] registered for url pattern(s) [[/]] and servlet name(s) [[]] 2022-06-23 14:33:31.380 INFO 24620 --- [ main] o.g.grizzly.servlet.WebappContext : [application] Filter [org.springframework.boot.web.servlet.filter.OrderedFormContentFilter] registered for url pattern(s) [[/]] and servlet name(s) [[]] 2022-06-23 14:33:31.381 INFO 24620 --- [ main] o.g.grizzly.servlet.WebappContext : [application] Filter [org.springframework.web.filter.RequestContextFilter] registered for url pattern(s) [[/]] and servlet name(s) [[]] 2022-06-23 14:33:31.381 INFO 24620 --- [ main] o.g.grizzly.servlet.WebappContext : Application [application] is ready to service requests. Root: []. 2022-06-23 14:33:31.664 INFO 24620 --- [ main] o.g.grizzly.http.server.NetworkListener : Started listener bound to [0.0.0.0:8082] 2022-06-23 14:33:31.666 INFO 24620 --- [ main] o.g.grizzly.http.server.HttpServer : [HttpServer] Started.
Access error: