package demo;
import jersey.repackaged.com.google.common.collect.Sets;
import org.glassfish.jersey.servlet.ServletContainer;
import org.glassfish.jersey.servlet.ServletProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import java.util.Set;
@ComponentScan
@EnableAutoConfiguration
public class Application extends SpringBootServletInitializer {
private static Class<Application> entryPointClass = Application.class;
public static void main(String[] args) {
SpringApplication.run(entryPointClass, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(entryPointClass);
}
@Bean
public ServletRegistrationBean jerseyServlet() {
ServletRegistrationBean registration = new ServletRegistrationBean(new ServletContainer(), "/*");
registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, JaxRsApplication.class.getName());
return registration;
}
public static class JaxRsApplication extends javax.ws.rs.core.Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = Sets.newHashSet();
classes.add(GreetingEndpoint.class);
return classes;
}
}
}