Skip to content
GWT Spring Boot Archetype
Documentation / Archetype reference

Archetype reference

What the archetypes generate and how the generated project is configured.

Maven coordinates

ArchetypegroupIdartifactId
Clean skeletonio.github.nalukit.archetypeclean-modular-springboot-webapp
With example codeio.github.nalukit.archetypemodular-springboot-webapp

Use -DarchetypeVersion=LATEST for the newest release. To try a local build, install the project with mvn clean install and generate with -DarchetypeVersion=HEAD-SNAPSHOT.

Archetype properties

PropertyDefaultMeaning
groupId, artifactId, version, packageasked by MavenStandard Maven archetype properties of the generated project
moduleAppName of the GWT module and its entry point class, for example Basic
module-short-namelower case moduleShort name of the GWT module, used in the servlet path of the example and as moduleShortName in the client module
mvn archetype:generate \
  -DarchetypeGroupId=io.github.nalukit.archetype \
  -DarchetypeArtifactId=modular-springboot-webapp \
  -DarchetypeVersion=LATEST \
  -DgroupId=com.example -DartifactId=myapp -Dversion=0.1-SNAPSHOT \
  -Dpackage=com.example.myapp -Dmodule=MyApp -Dmodule-short-name=myapp

Generated versions

ComponentVersionProperty in the parent POM
Java17maven.compiler.source (server), sourceLevel (GWT plugin)
GWT2.13.1gwt.version
Spring Boot4.1.0spring-boot.version
SnakeYAML2.6snakeyaml.version
gwt-maven-plugin1.2.0plugin management

The parent POM imports the GWT and Spring Boot dependency management. Change the versions in its properties section.

Module layout

The generated project consists of a parent POM and three modules, named after your artifactId:

ModulePackagingContent
<artifactId>-clientgwt-appGWT module descriptor module.gwt.xml and the entry point class. Depends on gwt-user, gwt-dev and on the shared module, including its sources.
<artifactId>-sharedjarCode used by client and server. Builds a sources JAR for the GWT compiler. gwt-servlet-jakarta is provided.
<artifactId>-serverwarSpring Boot application, application.yaml, static files under public and web.xml. Depends on the shared module and, at runtime, on the client module.
myapp/
├── pom.xml
├── readme.txt
├── myapp-client/
│   ├── pom.xml
│   └── src/main/
│       ├── module.gwt.xml
│       └── java/…/App.java
├── myapp-shared/
│   ├── pom.xml
│   └── src/main/java/…
└── myapp-server/
    ├── pom.xml
    └── src/main/
        ├── java/…/Application.java
        ├── resources/application.yaml
        ├── resources/public/ (index.html, css, favicon.ico)
        └── webapp/WEB-INF/web.xml

Clean skeleton vs. example

Moduleclean-modular-springboot-webappmodular-springboot-webapp
clientEmpty entry point with an onModuleLoad() methodExample entry point that calls the greeting service
sharedpackage-info.java onlyGreetingService, GreetingServiceAsync, GreetingResponse and FieldVerifier
serverApplication, configuration and start pageAdditionally GreetingServiceImpl, a servlet for the GWT-RPC service

GWT module and client build

The client module inherits the GWT user library and the Clean theme, and declares the entry point:

<module>
  <inherits name="com.google.gwt.user.User" />
  <inherits name="com.google.gwt.user.theme.clean.Clean" />
  <source path="" />
  <entry-point class="${package}.${module}" />
</module>

The client POM configures the gwt-maven-plugin with moduleName, moduleShortName and a work directory under target/gwt. The parent POM points the plugin's launcherDir to <artifactId>-server/target/classes/launcherDir/. This is how the server serves the compiled GWT application.

Spring Boot server

Application extends SpringBootServletInitializer, so the WAR also runs in an external servlet container. It is annotated with @SpringBootApplication and @ServletComponentScan, which lets Spring find servlets annotated with @WebServlet. A nested component sets the document root to launcherDir when that directory exists. GWT-RPC needs this to find its serialization policy files during development.

Setting in application.yamlValue
server.port8080
spring.web.resources.static-locationsclasspath:/launcherDir/,classpath:/public/
spring.application.nameyour artifactId
spring.servlet.multipart.max-file-size / max-request-size20MB
server.error.whitelabel.enabledfalse

The server build repackages the WAR with the spring-boot-maven-plugin and names it after the artifactId (finalName). spring-boot-starter-tomcat is provided, and spring-boot-devtools is included for development.

Example GWT-RPC service

Only in modular-springboot-webapp. The shared module declares the service, the server implements it as a servlet:

@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
  GreetingResponse greetServer(String name) throws IllegalArgumentException;
}

@WebServlet("/${module-short-name}/greet")
public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService {
  // …
}

The relative path greet is resolved against the GWT module base URL, which contains the module-short-name. Both parts therefore fit together without further configuration.

Contributing

Clone the repository and run mvn clean verify. The build generates sample projects from both archetypes and compares them with reference projects. The generated samples are located in target/test-classes/projects/basic-webapp/project/basic-webapp of each archetype module. See the repository README.