Customize the starter class of springboot

1. Create a maven project

  • create name
    insert image description here
    insert image description hereinsert image description hereinsert image description here

2. Create a folder (the name can be arbitrary)

insert image description here

3. Create a class (a common class, a configuration class)

  • configuration class
    insert image description hereinsert image description here
  • common class
    insert image description here

4. Introduce dependencies

insert image description here

5. Create a META-INF creation file under the resource folder

  • Automatically load the value of the configuration class to fill in the path of the configuration class
    insert image description here

6. Make jar package

  • Click the maven project on the right to package it into a jar package
  • Description: install is to package the project into a jar and put it in the maven warehouse
  • After the packaging is complete, find the corresponding jar package in the local maven warehouse
    insert image description hereinsert image description here

7. Create a new springboot project and introduce a custom startup class in the pom of the new project

  • When introduced, the groupId and artifactId correspond to the groupId and artifactId in the custom startup class project respectively
    New springboot projectCustom startup class projectinsert image description here

8. Create a Controller folder and automatically inject the target class

insert image description hereinsert image description here

9. Test

insert image description hereinsert image description here

.

Guess you like

Origin blog.csdn.net/qq_42785250/article/details/103742605