Giriş
Şu satırı dahil ederiz
import jakarta.ws.rs.ApplicationPath;
Örnek
Şöyle yaparız. /api/* isteklerini karşılayan bir servlet başlatır
import jakarta.ws.rs.ApplicationPath;import jakarta.ws.rs.core.Application; @ApplicationPath("api") public class JerseyConfigs extends Application { } // Access as /api/hello import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; @Path("hello") public class HelloController { @GET public String getHello() { return "Hello, JAX-RS !!!"; } }
Açıklaması şöyle
By simply extending the Application class from JAX-RS, and adding the @ApplicationPath annotation, now you’ve configured Jersey.Through the annotation you can define the url pattern, and other Jersey configurations can be added by overriding methods in the Application class.Note we didn’t specify packages to scan, what will happen is that jersey will scan all our application classes for JAX-RS annotated classes.
Örnek
Şöyle yaparız. /api/* isteklerini karşılayan bir servlet başlatır
import jakarta.ws.rs.ApplicationPath;import jakarta.ws.rs.core.Application;@ApplicationPath("api")public class BaseApplication extends Application {}
Hiç yorum yok:
Yorum Gönder