springboot+mybatis+mysql建立簡單web後台項目

來源:互聯網
上載者:User

標籤:project   rop   server   spring   release   insert   簡單的   word   username   

第一步:搭建架構

建立進入這個頁面

建立名字,第一次可以預設,然後下一步

第三步:選擇依賴

第四步:建立項目名和存放項目路徑(你可以建立一個檔案夾存放)

點擊finish,首次建立Springboot的時候下載依賴會比較慢,耐心等一會,下載好依賴後就可以了

 第五步:resources--application.properties寫串連mysql資料庫的載入,上資料,怕你們寫錯,複製下來修改為自己的資料庫和連接埠號碼就行了

#資料庫載入
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

第六步:pom.xml依賴,都是springboot自動產生下載的依賴,因為我們現在是做簡單的項目操作,後面要加其他依賴就後面會再寫,最主要的就是這幾個依賴

<?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 -->
</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>
<!--測試-->
<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>
第七步:建包

然後建立類

1.實體類(Alt+Insert可以快速構建GET AND SET 還有 toString() 方法)

2.建立Mapper,這是一個  interface  

3.業務層

4實現Contorller

建資料庫

 啟動服務,出現這個頁面就是對的

然後就成功了,就調用方法實現

springboot+mybatis+mysql建立簡單web後台項目

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.