spring boot的pom.xml配置文件内容

本文详细介绍了如何使用Spring Boot构建Maven项目,涉及parent配置、项目信息设置、JDK版本指定、依赖管理(包括starter-web、mybatis-spring-boot等)以及maven插件的配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


头部文件,标明版本等

<?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">
    *<!--1.1 模型版本-->*
    <modelVersion>4.0.0</modelVersion>

2. 设置parent

*<!--    Spring Boot的项目必须要将parent设置为Spring Boot的parent,该 parent包含了大量默认的配置,-->
<!--    大大简化了我们的开发。-->*
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

1. 项目信息

 *<!-- 1.2 公司或者组织的唯一标志,并且配置时生成的路径也是由此生成, 如com.neu,maven会将该项 目打成的jar包放本地路径:/com/neu -->*
    <groupId>com.neu</groupId>
    <artifactId>demoboot001</artifactId>
    *<!-- 1.3版本号 -->*
    <version>0.0.1-SNAPSHOT</version>
    *<!-- 1.4项目的唯一ID,一个groupId下面可能多个项目,就是靠artifactId来区分的 -->*
    <name>demoboot001</name>
    <description>Demo project for Spring Boot</description>

3. 设置jdk版本

    <properties>
        <java.version>1.8</java.version>
    </properties>

4. 设置依赖starter

<!--    spring-boot-starter-web:支持全栈式Web开发,得到一个可执行的基于 SpringMVC 的web应用,默-->
<!--    认使用嵌入式tomcat作为web容器对外提供http服务-->
<!--    spring-boot-starter-tomcat:引入了Spring Boot默认的HTTP引擎Tomcat-->
<!--    spring-boot-starter-test:测试模块,包括JUnitHamcrestMockito以及 spring-test模块-->
 <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <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>

5. maven插件

 <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>
        </plugins>
    </build>

</project>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值