IDEA creates a new SpringBoot project (simple)

1. Create a project, select JDK

2. Edit the project name (note that Artifact cannot be mixed in upper and lower case)

3. Use Mybatis for the persistence layer and select Spring web

Click next and then click Finish

The structure of a SpringBoot project is shown in the figure (the Controller package and the files in it are created by myself for testing, and I deleted a layer of directory structure)

Wait for testing.

The main class of SpringBoot lies in this Application class. Because Mybatis is checked, spring boot will load the org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration class by default. The DataSourceAutoConfiguration class uses the @Configuration annotation to inject a dataSource bean into spring. Because there is no configuration information related to dataSource in the project, when Spring creates a dataSource bean, it will report an error due to lack of relevant information.

We just test it and add it directly to the Application class

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

Start it, and enter http://localhost:8080/login on the browser address

Such a SpringBoot is built

You can also download the demo from the official website

https://start.spring.io/

Guess you like

Origin blog.csdn.net/qq_40210804/article/details/103601608