Now works with mvn jetty:run

This commit is contained in:
jvi
2020-09-07 15:04:12 +02:00
parent dc34e6f785
commit 4dc398c5a1
5 changed files with 51 additions and 67 deletions

View File

@@ -1,18 +1,24 @@
package ca.uhn.fhir.jpa.starter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import java.util.Arrays;
@ServletComponentScan(basePackageClasses = {JpaRestfulServer.class}, basePackages = "ca.uhn.fhir.jpa.starter")
@SpringBootApplication(exclude = ElasticsearchRestClientAutoConfiguration.class)
public class Application {
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
@@ -23,6 +29,27 @@ public class Application {
//UI is now accessible at http://localhost:8080/
}
@Override
protected SpringApplicationBuilder configure(
SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
@Autowired
AutowireCapableBeanFactory beanFactory;
@Bean
public ServletRegistrationBean hapiServletRegistration() {
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
JpaRestfulServer jpaRestfulServer = new JpaRestfulServer();
beanFactory.autowireBean(jpaRestfulServer);
servletRegistrationBean.setServlet(jpaRestfulServer);
servletRegistrationBean.addUrlMappings("/hapi-fhir-jpaserver/fhir/*");
servletRegistrationBean.setLoadOnStartup(1);
return servletRegistrationBean;
}
@Bean
public ServletRegistrationBean servletRegistrationBean() {

View File

@@ -11,7 +11,9 @@ import ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor;
import ca.uhn.fhir.jpa.bulk.provider.BulkDataExportProvider;
import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor;
import ca.uhn.fhir.jpa.partition.PartitionManagementProvider;
import ca.uhn.fhir.jpa.provider.*;
import ca.uhn.fhir.jpa.provider.GraphQLProvider;
import ca.uhn.fhir.jpa.provider.IJpaSystemProvider;
import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2;
import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3;
import ca.uhn.fhir.jpa.provider.r4.JpaConformanceProviderR4;
import ca.uhn.fhir.jpa.provider.r5.JpaConformanceProviderR5;
@@ -35,13 +37,14 @@ import org.springframework.http.HttpHeaders;
import org.springframework.web.cors.CorsConfiguration;
import javax.servlet.ServletException;
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class BaseJpaRestfulServer extends RestfulServer {
@Autowired
DaoRegistry daoRegistry;

View File

@@ -6,7 +6,7 @@ import javax.servlet.annotation.WebServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
@WebServlet(urlPatterns = {"/hapi-fhir-jpaserver/fhir/*"})
//@WebServlet(urlPatterns = {"/hapi-fhir-jpaserver/fhir/*"})
@Import(AppProperties.class)
public class JpaRestfulServer extends BaseJpaRestfulServer {