Springboot+mybatis+mysql creating a simple Web background project

Source: Internet
Author: User

The first step: building a framework

New enter this page

New name, first time can default, then next

Step Three: Select dependencies

Fourth step: Create a new project name and store the project path (you can create a new folder to store)

Click Finish, the first time you create a springboot download dependency will be slow, patience wait a while, download the dependency on it.

Fifth Step: Resources--application.properties write connection MySQL database load, on the data, afraid you write wrong, copy down to modify for their own database and port number on the line

#数据库加载
Spring.datasource.url=jdbc:mysql://localhost:3306/sbm?characterencoding=utf-8&useunicode=true
Spring.datasource.username=root
spring.datasource.password=lj1234
Spring.datasource.driverclassname=com.mysql.jdbc.driver

#页面热加载
Spring.thymeleaf.cache=false

#端口
server.port=6050

The sixth step: Pom.xml dependent, are springboot automatically generate download dependencies, because we are now doing a simple project operation, the following to add other dependencies will be written later, the most important is that these several dependencies

<?xml version= "1.0" encoding= "UTF-8"?>
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"

xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >

<modelVersion>4.0.0</modelVersion>

<groupId>com.dome</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>demo</name>
<description>demo Project for Spring boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!--lookup parent from repository to
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<!--jdbc-->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!--web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--mybatis-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<!--mysql-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--test-
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Seventh Step: Build a Package

Then create the class

1. Entity classes (Alt+insert can quickly build get and SET with the ToString () method)

2. Create mapper, which is a interface

3. Business Layer

4 Implementation Contorller

Build Database

Start the service, the page that appears is right

And then it succeeds, calling the method implementation

Springboot+mybatis+mysql creating a simple Web background project

Related Article

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.