Learn Spring Boot

News

@Autowired Injecting Arrays and Collections in Spring Boot

In the spring boot, @Autowired injects object arrays and java collections. Java collections such as list, set, map, array are injected using the @Autowired annotation. Collections commonly used, such as ArrayList, HashMap, HashTable, HashSet, TreeHashMap, can be automatically wired using @Autowired on the spring boot. The @Autowired annotation creates java

Spring Boot Security Database Authentication using UserDetailsService Example

In spring boot security, we see the database authentication and authorization using UserDetailsService in this example. The UserDetailsService is configured in spring boot security configuration class WebSecurityConfigurerAdapter. The mysql database, spring boot MVC, spring boot security, tomcat web server and jsp files are used to authenticate and authorize the user

Multiple Login Pages using Spring Boot Security with Database Authentication

In Spring Boot Security, we will discuss how to create multiple login pages using spring boot security with database authentication and authorization for different users role such as admin, user in the custom login pages in spring boot. In real-time applications, we needed to have different login pages to be

Two Login Form in One Login Page Spring Boot Security

In this post, we will see how to create two login form in a login page using spring boot security in java. The spring boot security module is used to validate these two login forms in one login page. The multiple login forms can be added as like the example

Spring Boot @Value Annotation

In this article, we will see about the spring boot annotation @Value. The annotation @Value is used to automatically assign a value from multiple environment such as spring environment, system environment, property files, bean objects, default value etc. The annotation @Value in spring boot is commonly used to inject the

How to enable Hibernate logs in Spring Boot

In Spring boot, hibernate logs should be enabled to debug the database connection and SQL query execution. By default hibernates logs are disabled in spring boot application. The hibernate logs can be enabled using the spring boot configurations. There are different configuration parameters that logs different features of hibernate. For

Print Hibernate SQL query string with parameter values in Spring

In the spring boot application, if the hibernate log is enabled using the JPA spring boot configuration, the sql query will be printed. The value of the parameters is not logged in the hibernate log files. The default JPA spring boot configuration will enable sql queries to be logged as they are. Configuration will not enable the values of the parameter to log. If the sql query log is enabled using the hibernate logger directly, the hibernate class will log the query and query parameter values. The spring boot JPA will allow to print only sql queries. Hibernate log JPA Configuration The following jpa configurations will enable hibernate log in the spring

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The spring boot exception com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure happens when the java mysql database driver is unable to connect to mysql database. The Java application was unable to establish communication between mysql database driver and mysql database. The Jdbc connection between the java and mysql database could not be established.

Cannot load driver class: com.mysql.jdbc.Driver

The database exception Cannot load driver class: com.mysql.jdbc.Driver occurs if there is a disparity between mysql driver class, mysql driver jar version and mysql database version. The java application attempts to load a driver class from the mysql database driver jar. If the driver class is unable to load, the

RuntimeException: Driver claims to not accept jdbcUrl

Spring boot RuntimeException java.lang.RuntimeException: Driver claims to not accept jdbcUrl happens when an inappropriate data source url is configured to connect to a database. The database driver can accept the jdbc url in a particular format. If the jdbc url format is different from expected one, RuntimeException Driver claims to

Most Viewed