Unlike spring-boot, JakartaEE applications usually organizes application code apart from server code.
Java web projects used to be packaged into war or ear files and the server was managed separately.
I am trying to find a project layout for JakartaEE projects that comply with separation but behaves more like a springboot app and, in order to get it, i am exploring the embedded app servers approach.
So far, i am thinking on a multiproject layout, one with regular JEE style structure and another with an embedded app server consuming the first one. Gradle and maven both supports it:
- https://docs.gradle.org/current/userguide/multi_project_builds.html
- https://books.sonatype.com/mvnex-book/reference/multimodule-sect-simple-parent.html
For the embedded app server i found these samples so far:
- https://blog.payara.fish/what-is-payara-embedded?
- https://www.ibm.com/docs/en/was-liberty/zos?topic=liberty-embedding-server-in-your-applications
- Simple Embedded Tomcat 10 Example
- https://github.com/wildfly/wildfly-core/blob/main/embedded/src/test/java/org/wildfly/core/embedded/EmbeddedServerFactorySetupUnitTestCase.java
- https://www.eclipse.org/jetty/documentation/jetty-11/programming-guide/index.html#creating-helloworld-class
A good article on this topic follows:
For the project layout i don't have much ideas yet, i am only sure about the separation of the two modules. A few questions so far:
- should the embedded final jar file be an uber jar?
- should the war/ear artifact be repackaged?
- why this approach isn't more popular, given the clear success of sprin boot?