Spring Boot + GWT embedded configuraiton
embeddedwebserver, gwt, spring-boot
Solution
After long search & test, here is the solution that I come up with:
<!-- POM --> <modelVersion>4.0.0</modelVersion> <groupId>fr.ekito.gwt</groupId> <artifactId>gwt-boot</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>Ekito Spring Boot GWT WebApp</name>
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.2.5.RELEASE</version> </parent>
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <start-class>fr.ekito.gwt.server.ServerApplication</start-class> <java.version>1.7</java.version>
<gwtVersion>2.6.0</gwtVersion> <googleGin>2.1.2</googleGin> <outputFolder>${project.build.directory}/${artifactId}</outputFolder> </properties>
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-undertow</artifactId> <exclusions> <exclusion> <groupId>io.undertow</groupId> <artifactId>undertow-websockets-jsr</artifactId> </exclusion> </exclusions> </dependency>
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> </dependency>
<dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-user</artifactId> <version>${gwtVersion}</version> </dependency> <dependency> <groupId>com.google.gwt.inject</groupId> <artifactId>gin</artifactId> <version>${googleGin}</version> </dependency> </dependencies>
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>${start-class}</mainClass> <layout>ZIP</layout> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gwt-maven-plugin</artifactId> <version>${gwtVersion}</version> <executions> <execution> <goals> <goal>compile</goal> </goals> </execution> </executions> <configuration> <runTarget>GwtWebApp.html</runTarget> <persistentunitcachedir>${project.build.directory}</persistentunitcachedir> <deploy>${project.build.directory}/gwt-deploy</deploy> <webappDirectory>${project.build.directory}/classes/public</webappDirectory> </configuration> </plugin> </plugins> </build>
my project structure is is same with original project, https://github.com/Ekito/spring-boot-gwt, except some little changes:
- Instead of webapp folder, I have src/main/resources/public folder, and html & css file is there.
- No need for web.xml file, spring-boot take care of it.
- No need for WEB-INF folder.
As a result, I have a runable jar, but run by org.springframework.boot.loader.PropertiesLauncher. Single jar works as expected, Tomcat doesnt work as stated here: http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-jsp-limitations.
Also, I can move the lib folder outside the jar file, but I in order to set the `loader.path` property, I need to put it to application.properties inside the jar file. I should be able to use -Dloader.path but didn't work.
I'll check with spring team. But so far, it's promising.
Problem
I want to configure Spring Boot Embedded Servlet Container + GWT. The way I want is either create a jar/war file that just contains the compiled gwt files & static resources. I want to load jars from lib/* and config files from classpath. I couldn't find any working example. There is one actually, https://github.com/Ekito/spring-boot-gwt, but all the dependencies and configs are still in the war. Can someone suggest a solution ?