SpringBoot练习-依赖添加

文章展示了Springboot项目的基础依赖配置,包括spring-boot-starter-web、spring-boot-starter-thymeleaf、spring-boot-devtools(热部署)、spring-boot-starter-test以及Mybatis、MySQL驱动和Druid连接池。还提到了Lombok库用于生成getter、setter等方法。
摘要由CSDN通过智能技术生成

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>

    <!-- 通过依赖 spring-boot-starter-parent,继承该模块,创建为springboot工程 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.0</version>
    </parent>

    <groupId>org.example</groupId>
    <artifactId>SwjtuScoreManaSys</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!-- 添加额外的依赖 -->
    <dependencies>
        <!-- spring公司下的依赖不需要每次添加版本号,延用父工程的版本号 -->
        <!-- web模块 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- thymeleaf视图技术 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <!-- 热部署项目 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>      <!-- 这个需要为true,热部署才有效 -->
        </dependency>

        <!-- 测试相关的依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- 数据库相关 -->
        <!-- Mybatis -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.0.0</version>
        </dependency>

        <!-- 驱动程序 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>

        <!-- 连接池 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.1.9</version>
        </dependency>

        <!-- 工具:辅助生成get和set,toString,构造函数等方法 -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
    </dependencies>

</project>

如果你想进行Spring Boot练习,以下是一些建议: 1. 创建一个简单的Spring Boot项目:使用Spring Initializr(https://start.spring.io/)创建一个基本的Spring Boot项目,选择合适的依赖项(如Spring Web、Spring Data JPA等)。 2. 控制器和路由:创建一个控制器类并添加一些路由(使用`@RequestMapping`或`@GetMapping`等注解),练习处理HTTP请求并返回响应。 3. 数据库操作:使用Spring Data JPA或其他ORM框架连接数据库,并编写一些CRUD操作的方法,练习数据库的增删改查。 4. 配置文件和属性:学习如何使用application.properties或application.yml文件来配置应用程序的属性,例如数据库连接信息、日志级别等。 5. RESTful API:设计并实现一组RESTful API,使用Spring Boot的注解(如`@RestController`、`@GetMapping`、`@PostMapping`等)处理请求和响应。 6. 异常处理:练习处理异常情况,如自定义异常类、全局异常处理器等。 7. 安全性和认证:学习如何使用Spring Security来保护你的应用程序,实现用户认证和授权。 8. 单元测试:编写单元测试来验证你的代码逻辑是否正确,使用Spring Boot提供的测试框架(如JUnit、MockMvc等)进行测试。 9. 日志记录:学习如何配置和使用日志记录框架(如Logback、Log4j),记录应用程序的运行日志。 10. 打包和部署:练习将你的Spring Boot应用程序打包成可执行的JAR文件,并部署到本地或远程服务器上。 以上是一些Spring Boot练习的建议,希望能帮助你开始学习和实践Spring Boot。如果还有其他问题,请继续提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值