In the previous recipe, we saw how we can view the database configuration properties defined in the database.properties
file using the database
properties
list
command. In this recipe, we'll look at how we can add, modify, or remove properties from the database.properties
file using the database
properties
set
and database
properties
remove
commands.
The following table shows the properties that we'll add, modify, and remove from the database.properties
file:
Refer to the Setting up a JPA provider for your project recipe to create the flight-app
Roo project and to set up a persistence provider using the persistence
setup
command.
Start the Roo shell from the C:
oo-cookbookch02-recipes
directory.
The following steps will show you how to add, modify, or remove properties:
database
properties
set
command is useful if you want to modify properties defined in the database.properties
file, as shown here:roo> database properties set --key database.username --value root roo> database properties set --key database.password --value asarin
database
properties
set
command can also be used to add new properties to the database.properties
file, as shown here: roo> database properties set --key database.modified.url --value jdbc:mysql://localhost:3406/myFlightAppDB roo> database properties set --key database.initialPoolSize --value 10
database
properties
remove
command is for removing an existing property from the database.properties
file, as shown here:roo> database properties remove --key database.url
The database
properties
set
and database
properties
remove
commands are processed by JPA add-on. Instead of using these commands you can use the properties
set
and properties
remove
command also, as shown in the Managing properties defined in a properties file recipe in Chapter 1, Getting Started with Spring Roo
It is important to note that if you modify the names of properties in the database.properties
file, then these modifications must be reflected in the dataSource
bean defined in the applicationContext.xml
file of your Roo project.
Instead of using Spring Roo, you can also modify the database.properties
file using an IDE like Eclipse or STS. Using Roo commands to modify the database.properties
file allows developers to replay the actions taken from the Roo shell using the script
command.
3.139.240.119