Day3_Springboot框架搭建

前面两天介绍了vue前端的主体框架,并完成了相关页面的部分设置,接下来开始介绍springboot后端开发的过程,手把手实践。包括项目的初始构建以及集成mybatis、mybatis-plus实现增删改查,分页查询,集成swagger-ui测试,前后端联调等。敬请期待~~~~~~

 

目录

1、创建springboot工程:

2、配置pom文件

3、配置application.properties连接数据库

4、navicat创建数据库

创建user表

 5. pom.xml

6、SpringBoot启动配置


1、创建springboot工程:

  • 点击 Spring Initializr , 选择 JDK 版本 ,选择 Default ,点击 Next;

  • 填写Group 和 Artifact 信息,选择对应的开发语言,打包方式,Java 版本等 ,点击 Next;

  • 选择 Web 依赖 和 Spring Boot 版本号,点击 Next;

  • 选择项目的保存位置,点击 FINISH

具体可以参考博客中内容,详细介绍了如何搭建springboot项目!!!

(8条消息) 使用Idea搭建SpringBoot项目_idea发布springboot项目_Siobhan. 明鑫的博客-CSDN博客

2、配置pom文件

pom里配置阿里云仓库

<repositories>
    <repository>
        <id>nexus-aliyun</id>
        <name>nexus-aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>public</id>
        <name>aliyun nexus</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

3、配置application.properties连接数据库

# Web Application Configuration
server.port=8088

# Database Configuration
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/gra_project?characterEncoding=utf8&serverTimezone=GMT%2b8
# 北京时间==东八区时间!=北京当地时间 serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root

也可改为yml形式,application.yml:(等号改为冒号+空格)使用 “key:(空格)value”格式配置属性,使用缩进控制层级关系。相比properties文件更简洁

server:
  port: 8088

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/gra_project?serverTimezone=GMT%2b8
    username: root
    password: root

4、navicat创建数据库

创建user表

 5. pom.xml

这里提供给大家我的pom文件,后续集成其他框架eg:mybatis、mybatis-plus、swagger等会再做补充! 

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.9</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.smx</groupId>
    <artifactId>gra-project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>gra-project</name>
    <description>The graduate project management system designed by Shen Mingxin</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- Mysql数据库驱动 -->
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!-- lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </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>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <!--修改版本-->
                <version>3.1.0</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

6、SpringBoot启动配置

 

下一节,我们更新springboot集成mybatis实现增删改查操作!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Siobhan.Mxin

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值