diff --git a/pom.xml b/pom.xml index f05e918..69dbab6 100644 --- a/pom.xml +++ b/pom.xml @@ -2,6 +2,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + org.springframework.boot spring-boot-starter-tomcat 2.3.3.RELEASE - test + org.springframework.boot spring-boot-autoconfigure 2.3.3.RELEASE - test + @@ -332,6 +319,20 @@ hapi-fhir-jpaserver + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + ca.uhn.fhir.jpa.starter.Application + + + + org.eclipse.jetty diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/Application.java b/src/main/java/ca/uhn/fhir/jpa/starter/Application.java new file mode 100644 index 0000000..21ce953 --- /dev/null +++ b/src/main/java/ca/uhn/fhir/jpa/starter/Application.java @@ -0,0 +1,42 @@ +package ca.uhn.fhir.jpa.starter; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; + +@ServletComponentScan(basePackageClasses = {JpaRestfulServer.class}) +@SpringBootApplication(exclude = ElasticsearchRestClientAutoConfiguration.class) +public class Application { + + public static void main(String[] args) { + + System.setProperty("spring.profiles.active", "r4"); + System.setProperty("spring.batch.job.enabled", "false"); + SpringApplication.run(Application.class, args); + + //Server is now accessible at eg. http://localhost:8080/fhir/metadata + } + + @Bean + public ServletRegistrationBean servletRegistrationBean() { + + AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); + + ctx.register(FhirTesterConfig.class); + + DispatcherServlet api = new DispatcherServlet(ctx); + api.setContextClass(AnnotationConfigWebApplicationContext.class); + api.setContextConfigLocation(FhirTesterConfig.class.getName()); + ServletRegistrationBean registrationBean = new ServletRegistrationBean(); + registrationBean.setServlet(api); + registrationBean.addUrlMappings("/*"); + registrationBean.setLoadOnStartup(1); + return registrationBean; + + } +} diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java b/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java index cc1a0b9..d9f6369 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java @@ -3,7 +3,7 @@ package ca.uhn.fhir.jpa.starter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; -@WebServlet +@WebServlet(urlPatterns = {"/fhir/*"}) public class JpaRestfulServer extends BaseJpaRestfulServer { private static final long serialVersionUID = 1L; diff --git a/src/main/resources/hapi.properties b/src/main/resources/hapi.properties index b7ef0f8..22a7b2f 100644 --- a/src/main/resources/hapi.properties +++ b/src/main/resources/hapi.properties @@ -11,7 +11,7 @@ fhir_version=R4 # (the web UI similar to the one at http://hapi.fhir.org) will use to # connect internally to the FHIR server, so this also needs to be a name # accessible from the server itself. -server_address=http://localhost:8080/hapi-fhir-jpaserver/fhir/ +server_address=http://localhost:8080/fhir enable_index_missing_fields=false auto_create_placeholder_reference_targets=false