Example of Maven project building spring boot + spring MVC + JPA
This paper introduces the example of Maven project building spring boot + spring MVC + JPA, which is shared with you as follows:
Add spring boot support and introduce related packages:
1. Maven project, no less POM For the introduction of XML and spring boot, please refer to the official website:
2. The above code introduces spring boot. Spring MVC and JPA, and the driver jar of MySQL database;
Write a startup class and add a configuration file:
1. The startup classes are as follows:
2. The location of the configuration file is placed outside the classpath to facilitate modification without repackaging. Spring boot projects are generally packaged into jar packages:
Put the configuration file in the config folder of the same level directory of the jar package, including log configuration, application YML files, other configuration files, etc;
Writing auto configuration classes
Used to scan compan * instead of spring MVC XML configuration file:
Write RS, service, repository
The above adopts the layered mode, which is a little cumbersome, but it is convenient to modify the business logic of each layer later
JPA related classes are as follows:
Entity class: related to database fields. Note the annotation @ mappedsuperclass in the lower parent class
Profile:
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.