Article From:

1  First, the pom. XML file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""


<!-- All springboot projects are based on the spring parent project - & gt;

<!--webRelevant dependencies - gt;
<!--Druid Connection Pool & gt;


2  Then there's the only configuration file in spring boot, application. properties, in the resource directory, which contains the configuration information for database connections, and all the other configuration queries are in it.

3  Create HelloController classes in the controller folder
public class HelloController01 {

public String test(){
return "hello world";


4  Add a boot class TestApplication to the upper directory of the controller folder
public class TestApplication {

public static void main(String[] args) {,args);


5  Start the main method to access localhost: 8080/hello

6  The method of establishing database connection and establishing a JdbcConfiguration class
public class JdbcConfiguration {
// To declare the prefix of the attribute to be injected, SpringBook automatically injects the relevant attribute into DataSource through the set method.
@ConfigurationProperties(prefix ="jdbc")
public DataSource dataSource(){

DruidDataSource wwdataSource=new DruidDataSource();
return wwdataSource;
In this class, the method name must be dataSource, and the return value or return type can be changed, but the method name must not be changed.

Leave a Reply

Your email address will not be published. Required fields are marked *