Java – how to configure spring boot applications to continue using resteasy?
I have an old web application (pure servlet without spring) and I want to run it as fat jar
Solution
You can use resteasy spring boot to start the program This is how you do it:
Add POM dependency
Add the following Maven dependency to the spring boot application POM file
<dependency> <groupId>com.paypal.springboot</groupId> <artifactId>resteasy-spring-boot-starter</artifactId> <version>2.1.1-RELEASE</version> <scope>runtime</scope> </dependency>
Registering jax-rs application classes
Just define your Jax - RS application class (subclass of application) as a spring bean and it will be registered automatically See the example below For details, see the jax-rs application registration method section in how to use resteasy spring boot starter
package com.test; import org.springframework.stereotype.Component; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; @Component @ApplicationPath("/sample-app/") public class JaxrsApplication extends Application { }
Register jax-rs resources and providers
Just define them as spring beans and they will be registered automatically Note that Jax - RS resources can be singletons or request scopes, and Jax - RS providers must be singletons
Further information at the project GitHub page.