Learn springboot from scratch (MYQSL link + port modification +JPA mapping)

Source: Internet
Author: User

1. Modify the port number: Add the Application.properties file: server.port=9090 will be able to change the port number to 9090

2. Connect to the database:

2.1: Modify Pom.xml Add

2.2:application.properties file Add:

########################################################
# # #datasource
########################################################
Spring.datasource.url = Jdbc:mysql://localhost:3306/fy
Spring.datasource.username = root
Spring.datasource.password = root
Spring.datasource.driverClassName = Com.mysql.jdbc.Driver
Spring.datasource.max-active=20
Spring.datasource.max-idle=8
Spring.datasource.min-idle=8
spring.datasource.initial-size=10


########################################################
# # JPA
########################################################
# Specify the DBMS
Spring.jpa.database = MYSQL
Spring.jpa.show-sql = True
Spring.jpa.hibernate.ddl-auto = Update
Spring.jpa.hibernate.naming-strategy = Org.hibernate.cfg.ImprovedNamingStrategy
Spring.jpa.properties.hibernate.dialect = Org.hibernate.dialect.MySQL5Dialect

3. Add DAO Interface

4. Writing Service Classes

5. Write a controller class

6. Visit Http://127.0.0.1:9090/demo2/save

7. The database saves a single piece of data

Learn springboot from scratch (MYQSL link + port modification +JPA mapping)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.