Every time we execute “composeUp” (or noClientComposeUp) the project starts a new database with the docker images, and every time we execute “composeDown” this database is deleted (as all the other docker containers). If you want to use an external database, to keep the data that you’ve created, please follow this guide.
Have your own database instance
The first thing to do is to have your Postgres database instance running, this needs to be a database accessible from your machine, so the application can access it too, you can install Postgres in you machine or even a virtual machine in the cloud. Tip: If you already have docker installed, you can run an instance inside a docker container executing few commands, for more information: postgres - Official Image | Docker Hub
Create a new database
Inside this new Postgres instance that you have running, you need to create a database exclusive for the project, save the name of the database and the login and password that you used to access Postgres.
Print screen using DBeaver:
Add Dev Profile
To use the property file for development (application-dev.properties) you need to change the environment variable, and this can be done via IDE or via terminal, it depends on how you are running the project.
Ps.: If you don’t want to use the dev properties file, you can copy the properties from application-dev.properties to application.properties, in this case you can skip this section “Add Dev Profile”, but this is not recommended since the information in the dev file should not go to production.
IDEA Variables
If you are running the project via IDE, you need to add this variable to the run configurations, here’s an example for IntelliJ IDEA:
-
Go to the main class and run it once
-
After that, IntelliJ will automatically create the run configuration and you will only need to edit it
-
To add the variable, go to your run configurations
-
Select the configuration which was just created, in this case it was “BapServerApplication”
-
Go to “Active profiles” field, under “Spring Boot” section
-
Change the value to “dev”
-
“Apply” and “Ok”
-
The next time you execute this run configuration, it will use this variable therefore using the application-dev.properties
Via Terminal
You can run the application via terminal (using Gradle) and to set the variable you will need to add a flag to the command, like this:
gradle :server:bootRun --args=‘–spring.profiles.active=dev’
Change files inside the project
Inside the project go to ~\server\src\main\resources\config there is a file called application-dev.properties inside this file you need to change the following properties:
- spring.datasource.url=jdbc:postgresql://localhost:5432/your-db-name > Replace “your-db-name” with the name of the database you’ve created before, and if the Postgres instance is running in other machine you can change "localhost:5432"
- spring.datasource.username=your-username > Replace “your-username” with the username that you used to access your Postgres instance
- spring.datasource.password=your-password > Replace "your-password" with the password that you used to access your Postgres instance
You also need to include the property:
mgm.services.core.search.startup=REBUILD_INDEX
This property makes the application loads the documents already inserted in the database.

Run the project
Go to the source directory of the project (the one with .gitignore file) and run “gradle build” to compile the project and then execute “gradle :server:bootrun” (don’t forget to put the flag “–-args” if you need application-dev as explained in the previous chapter).
Or simply by running the BapServerApplication on your IDE.
Troubleshoot
If you have a Postgres instance running in your machine it will probably conflict when you execute composeUp for any project based on full-stack-project-template, because composeUp will create another Postgres instance and it will use the same port 5432 (which is not possible).
What you can do is: change the default port from your Postgres instance (in this case don’t forget to change the port on application-dev.properties file) or stop the instance completely whenever you have to use composeUp. Tip: If you use the Postgres docker image you can just stop the container whenever you have to release the port.







