Java with Maven and Spring Boot
Two Spring Boot apps in one Maven multi-module build, run through the Maven Wrapper. web renders a Thymeleaf page and calls quotes over HTTPS with Spring’s RestClient, which trusts the devlanes CA through the trust store devlanes gives every JVM.
Requirements
Section titled “Requirements”- devlanes, with
devlanes setuprun once - JDK 21 or later; the Maven Wrapper downloads Maven itself
Run it
Section titled “Run it”cd languages-java-mavendevlanes startdevlanes start --no-ui prints the start as text:
✓ services readyexample-java-maven@0 · main✓ services 2 of 2 ready ✓ web https://example-java-maven.localhost ✓ quotes https://quotes.example-java-maven.localhostOpen https://example-java-maven.localhost. The page shows lane 0 of example-java-maven, the trust store the JVM uses and the answer of the lane’s quotes service.
During a start
Section titled “During a start”- The first start downloads Maven into
~/.m2/wrapperand the dependencies into~/.m2/repository, so both ready checks allow 5 minutes. webruns./mvnw -pl web -am spring-boot:runfrom the rootpom.xml.-amcompiles thesharedmodule first, and the parent pom skipsspring-boot:runin every module except the two apps.quotesruns./mvnw -pl quotes spring-boot:run, without-am: Maven has no build lock, so only one service buildsshared, andquotesdoes not depend on it.preset: spring-bootgives each appSERVER_PORT,SERVER_ADDRESS=127.0.0.1andSERVER_FORWARD_HEADERS_STRATEGY=framework.quotesnames amanagementport in itshosts, so it also getsMANAGEMENT_SERVER_PORTand serves the actuator on a port of its own.- Each service counts as ready once
/healthzanswers.
devlanes detects the java platform from pom.xml and adds -Djavax.net.ssl.trustStore=... to JAVA_TOOL_OPTIONS, pointing at a trust store with the system roots and the devlanes CA. Maven and the app JVM it forks both pick it up, which is why their logs start with Picked up JAVA_TOOL_OPTIONS. web gets QUOTES_URL from ${{ services.quotes.public_url }}, so its call goes through the proxy over HTTPS.
Try next
Section titled “Try next”Start a second lane:
git worktree add ../examples-checkout -b feat/checkout, thencd ../examples-checkout/languages-java-maven && devlanes start. https://example-java-maven1.localhost says lane 1, and itsquotesanswer comes from lane 1 too.The actuator answers on its own hostname. This prints
{"groups":["liveness","readiness"],"status":"UP"}, while the same path onquotes.example-java-maven.localhostis a 404 (on Windows add--ssl-revoke-best-effort):Terminal window curl -fsS https://actuator.quotes.example-java-maven.localhost/actuator/healthdevlanes env show web --explainlistsJAVA_TOOL_OPTIONSin thecontributorlayer, andSERVER_PORTand the other Spring variables from the preset.Change a quote in
quotes/src/main/java/com/acme/quotes/api/Quote.javaand rundevlanes restart quotes.spring-boot:runcompiles the change, and a reload of the page shows it.devlanes stop quotesand reload the page: the quotes card shows the 503 the proxy answers whilequotesis stopped.devlanes start quotesbrings it back.
devlanes.yaml: both services withrun_scriptonpom.xml,preset: spring-boot,hostsand themanagementport.pom.xml: the parent with the Spring Boot version and theskipsetting forspring-boot:run.shared/: the lane values and the typed quotes client inQuotesClient.java.web/src/main/java/com/acme/web/:config/Settings.javareads every variable, andpages/renders the templates.quotes/: the API and itsapplication.properties.