当前位置: 首页 > article >正文

2.SpringBoot项目pom.xml文件配置

1.pom.xml示例(初始项目创建时生成)

<?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>
    <groupId>com.store</groupId>
    <artifactId>store</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>store</name>
    <description>store</description>
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <spring-boot.version>2.7.6</spring-boot.version>
    </properties>
    <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.3.0</version>
        </dependency>

        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <configuration>
                    <mainClass>com.store.store.StoreApplication</mainClass>
                    <skip>true</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>repackage</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

2.pom解析

1)引入jar包,首先会尝试在本地Maven仓库加载,如果没有则会访问远程Maven仓库进行加载;包含groupId、artifactId、version三部分。

        <dependency>
            <groupId>com.example</groupId>
            <artifactId>jna</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>examples</artifactId>
            <version>1.0.0</version>
        </dependency>

2)Maven插件打war包

<plugin>
    <!--用以打war包-->
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>3.2.2</version>
</plugin>

3)将静态资源文件拷贝到war包的指定路径下

<plugin>
     <!--拷贝资源文件 copy-resources-->
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-resources-plugin</artifactId>
     <version>3.2.0</version>
     <executions>
         <execution>
             <id>copy-resources</id>
             <phase>package</phase>
             <goals>
                 <goal>copy-resources</goal>
             </goals>
             <configuration>
                 <resources>
                     <resource>
                         <!--打包前位置-->
                         <directory>${basedir}/lib</directory>
                     </resource>
                 </resources>
                 <!--打包后位置-->
                 <outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
             </configuration>
         </execution>
     </executions>
 </plugin>

4)常用依赖


        <!-- 二维码生成技术-zxing -->
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>core</artifactId>
            <version>3.5.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>javase</artifactId>
            <version>3.5.0</version>
        </dependency>

        <!--WebSocket依赖-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>
        <!--  压缩图片-->
        <dependency>
            <groupId>net.coobird</groupId>
            <artifactId>thumbnailator</artifactId>
            <version>0.4.8</version>
        </dependency>
	        <!-- gson -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.2</version>
        </dependency>
                <!--lombok-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <!-- 条形码生成技术-Barcode4j -->
        <dependency>
            <groupId>net.sf.barcode4j</groupId>
            <artifactId>barcode4j-light</artifactId>
            <version>2.0</version>
        </dependency>

        <!-- jeromq-->
        <dependency>
            <groupId>org.zeromq</groupId>
            <artifactId>jeromq</artifactId>
            <version>0.5.2</version>
        </dependency>

        <!-- base64 -->
        <dependency>
            <groupId>net.iharder</groupId>
            <artifactId>base64</artifactId>
            <version>2.3.8</version>
        </dependency>
               <!-- 添加redis依赖 -->
	   <dependency>
            <groupId>com.baosight.iplat4j</groupId>
            <artifactId>redis-plugin</artifactId>
            <version>1.0.1-SNAPSHOT</version>
        </dependency>

http://www.kler.cn/a/288750.html

相关文章:

  • 时序数据库TimescaleDB安装部署以及常见使用
  • MTSET可溶于DMSO、DMF、THF等有机溶剂,并在水中有轻微的溶解性,91774-25-3
  • 10款PDF翻译工具的探索之旅:我的使用经历与工具特色!!
  • jwt用户登录,网关给微服务传递用户信息,以及微服务间feign调用传递用户信息
  • Nginx配置自带的stub状态实现活动监控指标
  • #渗透测试#SRC漏洞挖掘#云技术基础02之容器与云
  • 【安卓面试】
  • 科学高效的FPGA编程方法
  • 从0到DevOps(1)-初步了解DevOps和容器
  • Nginx集成第三方负载均衡模块:配置指南与实践
  • 正则表达式模块re及其应用
  • 在K8s上运行GitHub Actions的自托管运行器
  • Swift 可选类型
  • 快速入门Pytorch
  • 搭子小程序开发,让社交更加有趣
  • AI赚钱成功案例|像素级拆解一键生成提示词 文生图 图生视频
  • Python 多目标跟踪-匈牙利算法
  • ArcGIS Pro SDK (十二)布局 7 组元素
  • Java算法之LRUCache缓存实现
  • 关于武汉芯景科技有限公司的A/D转换芯片XJ3021开发指南(兼容MCP3021)
  • 如何在已安装的最小化银河麒麟高级服务器操作系统上安装图形化界面
  • rtsp服务器逻辑
  • 学习react day01
  • C 语言都有哪些标准版本?
  • @RequestParam对于请求的影响
  • JVM类加载机制与双亲委派模型解析