A development loop is the cycle you repeat all day: start the app, change code, run the tests, look at the data, check that the running app is healthy. Each earlier part of this series covered one step. This part ties them together on one app, module 9 of the companion code, and adds the one thing that was missing: a way to switch settings, such as the database, without editing the project.
A profile is a named set of settings
A is a name that switches extra configuration on. Files called application-<name>.properties load only while that profile is active; the profiles article on this site explains the idea in detail (configuration, properties, profiles and SpEL). Module 9 has no profile files, and we did not change it. Spring Boot can read them from another folder with spring.config.additional-location, so we kept two files in ~/shop-config/, outside the repository:
# application-dev.properties
management.endpoints.web.exposure.include=health,info,metrics,loggers,env,beans,mappings
management.endpoint.health.show-details=always
logging.file.name=logs/shop.log
logging.structured.format.file=ecs
# application-pg.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/shop
spring.datasource.username=shop
spring.datasource.password=shop
spring.jpa.hibernate.ddl-auto=update
The dev profile turns on what Part 18 used. The pg profile points the app at a PostgreSQL database named shop; create it as in Part 11. The password sits in a local file only, so keep that folder out of Git.
One script to start the app
Module 9 has neither nor the PostgreSQL driver, so the script adds the jars from Part 18. Save it as ~/shop-config/run-shop.sh:
#!/bin/sh
cd ~/springuniverse-code
exec ./mvnw -B -pl module-09-catalog spring-boot:run \
-Dspring-boot.run.additional-classpath-elements="$(ls ~/shop-extras/lib/*.jar | paste -sd, -)" \
${JVM_ARGS:+-Dspring-boot.run.jvmArguments="$JVM_ARGS"} \
-Dspring-boot.run.arguments="--server.port=8091 --spring.config.additional-location=file:$HOME/shop-config/ --spring.profiles.active=$1"
sh ~/shop-config/run-shop.sh dev ran the app on H2, and the health endpoint reported database H2. dev,pg logged “The following 2 profiles are active” and reported PostgreSQL. Run it in the app pane of the layout from Part 14.
The loop
- Edit. Navigate, rename and fix with the keys of Parts 2 to 5.
- Test.
<leader>ttruns the class (Part 8). From the shell,./mvnw -B -pl module-09-catalog testran six tests with no failures. Tests use the module’s own H2 settings, because the profile folder is not passed to them. - Debug. Restart with
JVM_ARGS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" sh run-shop.sh dev,pg, then attach as in Part 7. Against the PostgreSQL app, a conditional breakpoint stopped onpage=1and not onpage=0, and detaching left the app answering HTTP 200. - Look at the data.
:DB postgresql://shop:shop@localhost:5432/shop select p.name, c.name as category from products p join categories c on c.id = p.category_id order by p.idreturned the four seeded products (Part 11). - Check the app.
:read !curl -s localhost:8091/actuator/health | jq '.components.db'put"database": "PostgreSQL"and"status": "UP"into a buffer (Part 18). - Read the logs. Raise
org.hibernate.SQLtoDEBUGthrough theloggersendpoint, then followlogs/shop.logwith:terminal tail -Fas in Part 18. - Profile when it is slow. Record with
jcmdand open a , as in Part 17.
Then change code and start again at step 1.
What we did and did not test
We ran every step above on a Linux box against the same app, with Neovim 0.12, JDK 25 and PostgreSQL 17. We did not record the whole loop as one continuous Neovim session; each step ran separately, and the debug step used the attach test from Part 7 against this app. We did not test macOS or Windows. There is no test profile: the tests keep the module’s default H2.
The folder, the script and the extra jars live outside the repository on purpose. In a project of your own, put spring-boot-starter-actuator and the PostgreSQL driver into pom.xml and keep the profile files beside the code. We left nvim-spring-ide unchanged for this part.
Recap
- A profile is a named set of settings;
application-<name>.propertiesloads only while that profile is active, andspring.config.additional-locationreads them from another folder. - Two profiles,
devfor Actuator and a log file andpgfor PostgreSQL, ran module 9 on H2 or PostgreSQL without any change to the repository. - One start script holds the Maven command;
JVM_ARGSadds the debug agent. - The loop is edit,
<leader>tt, attach and debug,:DB, an Actuator check withcurlandjq, then the log and, when needed, a flame graph. - Each step was tested on its own, not as one recorded session, and there is no test profile.
Series: Neovim as a Java IDE. Previous: Observing a running Spring Boot app from Neovim
Sources
Official documentation and well-known tutorials read while writing this article. The wording here is our own.
- Spring Boot reference: Profiles
- Spring Boot reference: Externalized configuration (config data locations)
- Spring Boot Maven plugin: Running your application
- Spring Boot reference: Actuator endpoints
- Baeldung: Spring Profiles
- Baeldung: Spring Boot Actuator
- Lorenzo Bettini: Neovim and Java with LazyVim, part 4: Running programs
- Nirmal Ravidas: Setting Up a Full Spring Boot Dev Environment on Linux with Neovim and LazyVim
Comments