How-to articles, tricks, and solutions about SPRING-BOOT

Add context path to Spring Boot application

To add a context path to a Spring Boot application, you can use the server.context-path property in the application's application.properties file.

How can I log SQL statements in Spring Boot?

To log SQL statements in Spring Boot, you can configure the logging level of the org.hibernate.SQL logger to DEBUG or TRACE.

How to access a value defined in the application.properties file in Spring Boot

To access a value defined in the application.properties file in Spring Boot, you can use the @Value annotation and the Environment interface.

How to configure port for a Spring Boot application

To configure the port for a Spring Boot application, you can use the server.port property in the application's configuration file. The configuration file can be a application.properties file in the classpath, or a application.yml file in the classpath.

Returning JSON object as response in Spring Boot

To return a JSON object as a response in Spring Boot, you can use the @ResponseBody annotation and the ObjectMapper class.

Setting active profile and config location from command line in spring boot

To set the active profile and the configuration location from the command line in Spring Boot, you can use the spring.profiles.active and spring.config.name properties.

Spring Boot - Cannot determine embedded database driver class for database type NONE

If you are seeing the error "Cannot determine embedded database driver class for database type NONE" in a Spring Boot application, it means that the application is trying to auto-configure an embedded database, but it is unable to determine which database

Spring Boot - Error creating bean with name 'dataSource' defined in class path resource

The error "Error creating bean with name 'dataSource' defined in class path resource" in Spring Boot typically indicates that there is a problem with the configuration of the dataSource bean.

Spring Boot and multiple external configuration files

To use multiple external configuration files with Spring Boot, you can use the spring.config.name property to specify the names of the configuration files.