Developer Docs

Running SpringBot with the dev profile

A SpringBot application can be run using different SpringBot application profiles and configuration to change its behaviour.

This article explores running your SpringBot application using the dev profile.

Setting environment specific configuration options

When using the dev profile, we want to set configuration options to specific values to match our local environment. To facilitate this, the dev profile allows us to set these values as environment variables.

The values in question are as follows:

Variable Value Comment
DATA_SOURCE_PASSWORD “bots” The password for our database.
DATA_SOURCE_USERNAME “codebots” The username of our database.
DATA_SOURCE_URL “jdbc:postgresql://localhost:5432/codebots” The connection string to our database.

To set these values we need to run the following commands in our terminal:

The values in these examples are based upon the database setup completed in the environment setup articles, please adjust these as necessary for your specific setup

Windows

$env:DATA_SOURCE_PASSWORD="bots"
$env:DATA_SOURCE_USERNAME="codebots"
$env:DATA_SOURCE_URL="jdbc:postgresql://localhost:5432/codebots"

To test that it worked, run each of the following commands:

$env:DATA_SOURCE_PASSWORD
$env:DATA_SOURCE_USERNAME
$env:DATA_SOURCE_URL

If the commands ran successfully, you should see something like the following:

PS > $env:DATA_SOURCE_PASSWORD
bots
PS > $env:DATA_SOURCE_USERNAME
codebots
PS > $env:DATA_SOURCE_URL
jdbc:postgresql://localhost:5432/codebots

Linux/Mac

export DATA_SOURCE_PASSWORD=bots
export DATA_SOURCE_USERNAME=codebots
export DATA_SOURCE_URL=jdbc:postgresql://localhost:5432/codebots

To test that it worked, run each of the following commands:

echo $DATA_SOURCE_PASSWORD
echo $DATA_SOURCE_USERNAME
echo $DATA_SOURCE_URL

If the commands ran successfully, you should see something like the following:

$ > echo $DATA_SOURCE_PASSWORD
bots
$ > echo $DATA_SOURCE_USERNAME
codebots
$ > echo $DATA_SOURCE_URL
jdbc:postgresql://localhost:5432/codebots

Persistent variables

To persist them, add them to your application-dev.properties file.

See SpringBot application profiles and configuration for more details regarding the available properties and profiles.

Navigate to your projects serverside directory.

cd /data/repository/[projectname]/serverside/

Edit the application properties file for the development environment. This can be found at src/main/resources/application-dev.properties .

Update the properties like so:

# % protected region % [Customise your connection details here] on begin
spring.datasource.url=${DATA_SOURCE_URL:jdbc:postgresql://localhost:5432/codebots}
spring.datasource.username=${DATA_SOURCE_USERNAME:codebots}
spring.datasource.password=${DATA_SOURCE_PASSWORD:bots}
 ...

Make sure you turn on the protected region!

Was this article helpful?

Thanks for your feedback!

If you would like to tell us more, please click on the link below to send us a message with more details.

Tool:

Generate

Iterate

Bot:

C#Bot

SpringBot

On this page

New to Codebots?

We know our software can be complicated, so we are always happy to have a chat if you have any questions.