Added boot application

This commit is contained in:
jkv
2020-09-04 23:23:04 +02:00
parent 53415f1c54
commit 5f237256ca
4 changed files with 62 additions and 19 deletions

35
pom.xml
View File

@@ -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"> 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">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<!-- mvn clean package spring-boot:repackage && java -jar target/hapi-fhir-jpaserver.war -->
<!-- <!--
Note: HAPI projects use the "hapi-fhir" POM as their base to provide easy management. Note: HAPI projects use the "hapi-fhir" POM as their base to provide easy management.
You do not need to use this in your own projects, so the "parent" tag and it's You do not need to use this in your own projects, so the "parent" tag and it's
@@ -117,7 +118,7 @@
<artifactId>hapi-fhir-testpage-overlay</artifactId> <artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<classifier>classes</classifier> <classifier>classes</classifier>
<scope>provided</scope>
</dependency> </dependency>
<!-- HAPI-FHIR uses Logback for logging support. The logback library is included automatically by Maven as a part of the hapi-fhir-base dependency, but you also need to include a logging library. Logback <!-- HAPI-FHIR uses Logback for logging support. The logback library is included automatically by Maven as a part of the hapi-fhir-base dependency, but you also need to include a logging library. Logback
@@ -275,33 +276,19 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.3.3.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.3.3.RELEASE</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat --> <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId> <artifactId>spring-boot-starter-tomcat</artifactId>
<version>2.3.3.RELEASE</version> <version>2.3.3.RELEASE</version>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId> <artifactId>spring-boot-autoconfigure</artifactId>
<version>2.3.3.RELEASE</version> <version>2.3.3.RELEASE</version>
<scope>test</scope>
</dependency> </dependency>
@@ -332,6 +319,20 @@
<finalName>hapi-fhir-jpaserver</finalName> <finalName>hapi-fhir-jpaserver</finalName>
<plugins> <plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>ca.uhn.fhir.jpa.starter.Application</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<!-- The following is not required for the application to build, but allows you to test it by issuing "mvn jetty:run" from the command line. --> <!-- The following is not required for the application to build, but allows you to test it by issuing "mvn jetty:run" from the command line. -->
<plugin> <plugin>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>

View File

@@ -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;
}
}

View File

@@ -3,7 +3,7 @@ package ca.uhn.fhir.jpa.starter;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
@WebServlet @WebServlet(urlPatterns = {"/fhir/*"})
public class JpaRestfulServer extends BaseJpaRestfulServer { public class JpaRestfulServer extends BaseJpaRestfulServer {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -11,7 +11,7 @@ fhir_version=R4
# (the web UI similar to the one at http://hapi.fhir.org) will use to # (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 # connect internally to the FHIR server, so this also needs to be a name
# accessible from the server itself. # 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 enable_index_missing_fields=false
auto_create_placeholder_reference_targets=false auto_create_placeholder_reference_targets=false