maven打包spring项目

news2025/2/3 19:07:08

常用的Maven命令如下

命令   说明
mvn clean    清理Maven 项目。会删除目标路径(一般是target目录)Maven生成的打包文件,编译文件。
mvn package    打包Maven项目,会生成jar 或者war文件。
mvn test    执行test目录下的测试用例。
mvn deploy    发布依赖到远端
mvn site    生成项目相关的信息
mvn archetype创建Maven 项目
mvn tomcat:run 运行在Tomcat容器
mvn install    安装依赖

jar包

打包到本地:

mvn clean install -Dmaven.test.skip=true

打包到远程仓库:

 mvn clean deplay -Dmaven.test.skip=true

说明:

clean: 是清除之前的jar包,

install:是打包到本地,

deploy:是打包到远程仓库

-Dmaven.test.skip=true :是忽略测试代码;

war包

mvn clean package -Dmaven.test.skip=true

maven的spring boot 打包分离依赖及配置文件

<!--省略 其他配置 -->
    <!--参数配置-->
    <properties>
        <package.output.basedir>${project.build.directory}/${project.artifactId}-${project.version}</package.output.basedir>
        <output.dependence.file.path>lib/</output.dependence.file.path>
        <output.resource.file.path>config/</output.resource.file.path>
        <output.shell.file.path>bin/</output.shell.file.path>
    </properties>

    <!--打包配置配置-->
    <build>
        <!-- 打包名称 如果需要包含时间戳,需要加入时间戳插件 -->
        <finalName>${project.artifactId}-${project.version}</finalName>

        <!--打包加GMT+8时间插件(默认是UTC时间少8小时)-->
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.4</version>
                <configuration>
                    <timestampFormat>yyyyMMddHHmmss</timestampFormat>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>create-timestamp</goal>
                        </goals>
                    </execution>
                </executions>
                <inherited>false</inherited>
            </plugin>

            <!--移除配置文件将其不打包进jar包中,并可以将打包后的jar包输出到指定路径 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <!-- 剔除配置文件或目录:注意从编译结果目录开始算目录结构excludes\includes 是根据编译后的classes这个路径计算的-->
                    <excludes>
                        <!-- 剔除指定后缀配置文件 -->
                        <exclude>*.properties</exclude>
                        <exclude>*.yml</exclude>
                        <!-- 剔除指定目录 -->
                        <!-- <exclude>/static/**</exclude>-->
                    </excludes>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <!-- MANIFEST.MF 中 Class-Path 各个依赖加入前缀 -->
                            <!--lib文件夹内容,需要 maven-dependency-plugin插件补充 (依赖包剥离位置)-->
                            <classpathPrefix>${output.dependence.file.path}</classpathPrefix>
                            <!-- jar包不包含唯一版本标识 -->
                            <useUniqueVersions>false</useUniqueVersions>
                            <!--指定入口类 -->
                            <mainClass>com.zhong.pacakge.springpacakage.PackageSpringPlugsApplication</mainClass>
                        </manifest>
                        <manifestEntries>
                            <!--MANIFEST.MF 中 Class-Path 加入自定义路径,多个路径用空格隔开 -->
                            <!--此处config文件夹的内容,需要maven-resources-plugin插件补充上 (配置文件剥离位置)-->
                            <Class-Path>./${output.resource.file.path}</Class-Path>
                        </manifestEntries>
                    </archive>
                    <!--输出目录 不指定则输出到target下-->
                     <outputDirectory>${package.output.basedir}//${output.dependence.file.path}</outputDirectory>
                </configuration>
            </plugin>

            <!-- 将依赖包导出到指定文件夹 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <!--依赖包的输出路径-->
                            <outputDirectory>${package.output.basedir}/${output.dependence.file.path}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- 将需要复制的文件复制到指定路径(例:将配置文件提取到指定路径) -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <!-- 复制配置文件 -->
                    <execution>
                        <id>resources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <!-- 复制哪些目录下的哪些文件到指定目录 -->
                            <resources>
                                <resource>
                                    <directory>src/main/resources</directory>
                                    <!-- 不配置excludes\includes默认就是复制指定目录的所有文件 -->
                                    <includes>
                                        <include>*.properties</include>
                                        <include>*.yml</include>
                                        <include>*/*.properties</include>
                                    </includes>
                                </resource>
                            </resources>
                            <outputDirectory>${package.output.basedir}/${output.resource.file.path}</outputDirectory>
                        </configuration>
                    </execution>
                    <!-- 启动类文件 位置-->
                    <execution>
                        <id>shell</id>
                        <phase>package</phase>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                        <configuration>
                            <!-- 复制哪些目录下的哪些文件到指定目录 -->
                            <resources>
                                <resource>
                                    <directory>src/bin</directory>
                                    <!-- 不配置excludes\includes默认就是复制指定目录的所有文件 -->
                                    <includes>
                                        <include>*.sh</include>
                                        <include>*.bat</include>
                                    </includes>
                                </resource>
                            </resources>
                            <outputDirectory>${package.output.basedir}/${output.shell.file.path}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- spring-boot-maven-plugin可以不使用,可当做一般jar包来运行,可统一包内文件结构- -->
            <!--<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    &lt;!&ndash;重写包含依赖,包含不存在的依赖,jar里没有pom里的依赖 &ndash;&gt;
                    <includes>
                        <include>
                            <groupId>non-exists</groupId>
                            <artifactId>non-exists</artifactId>
                        </include>
                    </includes>
                    <outputDirectory>${package.output.basedir}//${output.dependence.file.path}</outputDirectory>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            &lt;!&ndash;配置jar包特殊标识 配置后,保留原文件,生成新文件 *-run.jar &ndash;&gt;
                            &lt;!&ndash;配置jar包特殊标识 不配置,原文件命名为 *.jar.original,生成新文件 *.jar &ndash;&gt;
                            &lt;!&ndash;<classifier>run</classifier> &ndash;&gt;
                        </configuration>
                    </execution>
                </executions>
            </plugin>-->
            <!--maven打包时,跳过测试-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>


            <!-- 指定多个源代码目录、多个资源文件目录 -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/main/java</source>
                                <source>src/main/library</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- 编译插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

结果如下:

maven-assembly-plugin进行配置分离打包

assembly.xml配置参考官网:

Apache Maven Assembly Plugin – Assembly

 assembly.xml配置文件示例:

<?xml version="1.0" encoding="UTF-8"?>
<assembly>
    <!-- 可自定义,这里指定的是项目环境 -->
    <!-- xxx.tar.gz  -->
    <id>assembly</id>
    <!-- 打包的类型,如果有N个,将会打N个类型的包 -->
    <formats>
        <format>tar.gz</format>
        <format>zip</format>
    </formats>
    <!--压缩包是否包含 基于项目 基本目录的存档-->
    <includeBaseDirectory>true</includeBaseDirectory>

    <!--文件设置,参考:https://maven.apache.org/plugins/maven-assembly-plugin/assembly.html -->
    <fileSets>
        <!-- 配置文件打包-打包至config目录下 fileSet 可以多个-->
        <fileSet>
            <!--目标目录,会处理目录里面的所有文件-->
            <directory>${project.basedir}/src/main/resources/</directory>
            <!--打包后的目标文件夹-->
            <outputDirectory>config</outputDirectory>
            <!--指定打包的文件-->
            <includes>
                <include>*.xml</include>
                <include>*.properties</include>
                <include>common/*.properties</include>
            </includes>
            <!--排除的文件按-->
           <!-- <excludes>
                <exclude></exclude>
            </excludes>-->
            <!--目录权限:用户具有读/写/执行权限-->
            <directoryMode>0755</directoryMode>
            <!--文件权限:用户具有读/写/执行权限-->
            <fileMode>0755</fileMode>
            <!--脚本文件的编码问题在这里,要改为unix.如果是在windows上面编码,会出现dos编写问题-->
            <lineEnding>unix</lineEnding>
        </fileSet>
        <!--项目自己创建并依赖的jar-->
       <!-- <fileSet>
            <directory>../package-common/target</directory>
            <outputDirectory>jar</outputDirectory>
            <includes>
                <include>*.jar</include>
            </includes>
        </fileSet>-->
        <!-- 启动文件目录 -->
        <fileSet>
            <directory>${basedir}/src/bin</directory>
            <outputDirectory>bin</outputDirectory>
            <fileMode>0755</fileMode>
            <includes>
                <include>**.sh</include>
                <include>**.bat</include>
            </includes>
        </fileSet>
    </fileSets>

    <files>
        <!--包含打包后的jar文件,可以不加入<dependencySet>指定的 <outputDirectory/>,默认打包的目录-->
        <file>
            <source>${project.build.directory}/${project.build.finalName}.jar</source>
        </file>
        <!--这种方式也可以进行文件处理,但是针对单文件-->
        <!-- <file>
             <source>${project.basedir}/src/main/resources/script/start.sh</source>
             <fileMode>0755</fileMode>
             <lineEnding>unix</lineEnding>
         </file>-->
    </files>

    <dependencySets>
        <dependencySet>
            <!--是否把本项目添加到依赖文件夹下:-->
            <useProjectArtifact>false</useProjectArtifact>
            <!-- 将项目所有依赖包拷贝到发布包的lib目录下 :-->
            <outputDirectory>lib</outputDirectory>
            <!-- 符合runtime作用范围的依赖会被打包进去: -->
            <scope>runtime</scope>
            <!-- 这个是为了解决lib下同一个jar包可能有多个SNAPSHOT快照版的问题,比如后面加了不同的时间戳-->
            <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
            <fileMode>0755</fileMode>
            <excludes>
                <exclude>${project.groupId}:${project.artifactId}</exclude>
            </excludes>
        </dependencySet>
        <!--<dependencySet>
            &lt;!&ndash; 这个是为了解决lib下同一个jar包可能有多个SNAPSHOT快照版的问题,比如后面加了不同的时间戳&ndash;&gt;
            <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
            <outputDirectory>boot</outputDirectory>
            <fileMode>0755</fileMode>
            <includes>
                <include>${project.groupId}:${project.artifactId}</include>
            </includes>
        </dependencySet>-->
    </dependencySets>
</assembly>

 项目的pom.xml的build配置

<build>
        <!-- 打包后的启动jar名称 -->
       <!-- <finalName>${project.groupId}</finalName>-->
        <plugins>
            <!-- 用于排除jar中依赖包 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <includes>
                        <!-- 项目启动jar包中排除依赖包 -->
                        <include>
                            <groupId>non-exists</groupId>
                            <artifactId>non-exists</artifactId>
                        </include>
                    </includes>
                </configuration>
            </plugin>
            <!-- maven编译 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <!-- 不同版本需要制定具体的版本进行编译 -->
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

            <!-- 打包时跳过测试 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <!-- 打包插件 -->
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <!--文件夹名称, 就是打包后里面的文件夹名称-->
                    <finalName>${project.build.finalName}</finalName>
                    <!--指定压缩包的输出路径-->
                    <outputDirectory>${project.basedir}/target/package</outputDirectory>
                    <descriptors>
                        <!--assembly.xml配置位置-->
                        <descriptor>src/main/resources/assembly/assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <!-- 绑定到package生命周期阶段 -->
                        <phase>package</phase>
                        <goals>
                            <!-- 只运行一次 -->
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

使用idea的install功能或者执行命令 mvn package assembly:single

结果如下:

其他assembly.xml示例:将所有jar打到lib中

<?xml version="1.0" encoding="UTF-8"?>
<assembly>
    <!-- 可自定义,这里指定的是项目环境 -->
    <!-- xxx.tar.gz  -->
    <id>assembly</id>
    <!-- 打包的类型,如果有N个,将会打N个类型的包 -->
    <formats>
        <format>tar.gz</format>
        <format>zip</format>
    </formats>
    <!--压缩包是否包含 基于项目 基本目录的存档-->
    <includeBaseDirectory>true</includeBaseDirectory>

    <!--文件设置,参考:https://maven.apache.org/plugins/maven-assembly-plugin/assembly.html -->
    <fileSets>
        <!-- 配置文件打包-打包至config目录下 fileSet 可以多个-->
        <fileSet>
            <!--目标目录,会处理目录里面的所有文件-->
            <directory>${project.basedir}/src/main/resources/</directory>
            <!--打包后的目标文件夹-->
            <outputDirectory>config</outputDirectory>
            <!--指定打包的文件-->
            <includes>
                <include>*.xml</include>
                <include>*.properties</include>
                <include>common/*.properties</include>
            </includes>
            <!--排除的文件按-->
           <!-- <excludes>
                <exclude></exclude>
            </excludes>-->
            <!--目录权限:用户具有读/写/执行权限-->
            <directoryMode>0755</directoryMode>
            <!--文件权限:用户具有读/写/执行权限-->
            <fileMode>0755</fileMode>
            <!--脚本文件的编码问题在这里,要改为unix.如果是在windows上面编码,会出现dos编写问题-->
            <lineEnding>unix</lineEnding>
        </fileSet>
        <!--项目自己创建并依赖的jar-->
       <!-- <fileSet>
            <directory>../package-common/target</directory>
            <outputDirectory>jar</outputDirectory>
            <includes>
                <include>*.jar</include>
            </includes>
        </fileSet>-->
        <!-- 启动文件目录 -->
        <fileSet>
            <directory>${basedir}/src/bin</directory>
            <outputDirectory>bin</outputDirectory>
            <fileMode>0777</fileMode>
            <includes>
                <include>**.sh</include>
                <include>**.bat</include>
            </includes>
        </fileSet>
    </fileSets>

    <files>
        <!--包含打包后的jar文件,可以不加入<dependencySet>指定的 <outputDirectory/>,默认打包的目录-->
        <!--<file>
            <source>${project.build.directory}/${project.build.finalName}.jar</source>
        </file>-->
        <!--这种方式也可以进行文件处理,但是针对单文件-->
        <!-- <file>
             <source>${project.basedir}/src/main/resources/script/start.sh</source>
             <fileMode>0755</fileMode>
             <lineEnding>unix</lineEnding>
         </file>-->
    </files>

    <dependencySets>
        <dependencySet>
            <!--是否把本项目添加到依赖文件夹下:-->
            <useProjectArtifact>true</useProjectArtifact>
            <!-- 将项目所有依赖包拷贝到发布包的lib目录下 :-->
            <outputDirectory>lib</outputDirectory>
            <!-- 符合runtime作用范围的依赖会被打包进去: -->
            <scope>runtime</scope>
            <!-- 这个是为了解决lib下同一个jar包可能有多个SNAPSHOT快照版的问题,比如后面加了不同的时间戳-->
            <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
            <fileMode>0777</fileMode>
            <!--排除指定的文件,不放到lib文件夹-->
            <!--<excludes>
                <exclude>${project.groupId}:${project.artifactId}</exclude>
            </excludes>-->
        </dependencySet>
        <!--<dependencySet>
            &lt;!&ndash; 这个是为了解决lib下同一个jar包可能有多个SNAPSHOT快照版的问题,比如后面加了不同的时间戳&ndash;&gt;
            <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
            <outputDirectory>boot</outputDirectory>
            <fileMode>0755</fileMode>
            <includes>
                <include>${project.groupId}:${project.artifactId}</include>
            </includes>
        </dependencySet>-->
    </dependencySets>
</assembly>

结果如图:

 附上linux的执行脚本:

#!/bin/bash
# you can run script "sed -i 's/\r$//' start.sh" to format the file

SERVER_NAME=package-assembly-demo

#找到当前文件路径
cd `dirname $0`
#上册目录
cd ..
DEPLOY_DIR=`pwd`
MAIN_CLASS_NANE=PackageAssemblyApplication
MAIN_CLASS_PATH=com.zhong.pacakge.assemblydemo.PackageAssemblyApplication
LOGS_DIR=${DEPLOY_DIR}/logs
STDOUT_LOG_FILE=${LOGS_DIR}/stdout.log

#日志文件路径
if [ ! -d ${LOGS_DIR} ]; then
    mkdir ${LOGS_DIR}
fi
#日志文件权限
chmod -R 777 ${LOGS_DIR}


PIDS=`ps -ef | grep java | grep "$MAIN_CLASS_NANE" | awk '{print $2}'`
if [ -n "$PIDS" ]; then
    echo "ERROR: The $SERVER_NAME already started!"
    echo "PID: $PIDS"
    exit 1
fi

#-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=10101
CLASS_PATH=.:${DEPLOY_DIR}/config:${DEPLOY_DIR}/lib/*
JAVA_OPTS=" -server -Xmx1g -Xms1g -Xmn512m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "


echo "Starting the $SERVER_NAME ..."

nohup java ${JAVA_OPTS} -classpath ${CLASS_PATH} ${MAIN_CLASS_PATH} > ${STDOUT_LOG_FILE} 2>&1 &
sleep 5
if [ -n "$PIDS" ]; then
    echo "$SERVER_NAME started PID: $PIDS"
    exit 1
fi

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1427450.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Leetcode206:反转链表

一、题目 给你单链表的头节点 head &#xff0c;请你反转链表&#xff0c;并返回反转后的链表 示例&#xff1a; 输入&#xff1a;head [1,2,3,4,5] 输出&#xff1a;[5,4,3,2,1]输入&#xff1a;head [1,2] 输出&#xff1a;[2,1]输入&#xff1a;head [] 输出&#xff1…

面试经典 150 题 -- 滑动窗口 (总结)

面试经典150题链接 面试经典 150 题 - 学习计划 - 力扣&#xff08;LeetCode&#xff09;全球极客挚爱的技术成长平台 209 . 长度最小的子数组 思路 : 滑动窗口的思想&#xff0c;取ij0,向后遍历j,记录前缀和[l,r]为s,如果s>target,那么左端点向右移动&#xff0c;直到s…

net 一台路由器如何让两个不同网段的终端可以通信。

# 终端设备自己设置就行了 # 路由器的设置 The device is running! #################################################### <Huawei> Feb 1 2024 21:21:09-08:00 Huawei %%01IFPDT/4/IF_STATE(l)[0]:Interface GigabitEt hernet0/0/0 has turned into UP state. <…

Linux系统——防火墙

一、防火墙的认识 引言 安全技术 入侵检测系统&#xff08;Intrusion Detection Systems&#xff09;&#xff1a;特点是不阻断任何网络访问&#xff0c;量化、定位来自内外网络的威胁情况&#xff0c;主要以提供报警和事后监督为主&#xff0c;提供有针对性的指导措施和安全…

POI word操作,如何使表格单元格文本内容垂直/水平居中(两行代码解决)

垂直居中&#xff1a;cell本身就有垂直对齐的api&#xff0c;一行代码就够。 水平居中&#xff1a;一般方式行不通&#xff0c;网上苦找了许多方式&#xff0c;代码都太长了&#xff0c;&#xff0c;忒麻烦。于是我突发奇想&#xff0c;发现可以利用paragraph的水平居中对齐方…

Flask 入门3:Flask 请求上下文与请求

1. 前言 Flask 在处理请求与响应的过程&#xff1a; 首先我们从浏览器发送一个请求到服务端&#xff0c;由 Flask 接收了这个请求以后&#xff0c;这个请求将会由路由系统接收。然后在路由系统中&#xff0c;还可以挂入一些 “勾子”&#xff0c;在进入我们的 viewFunction …

小白水平理解面试经典题目_数组类Leetcode 412. Fizz Buzz【数学解法】

412 FizzBuzz 小白渣翻译&#xff1a; 给定一个整数 n &#xff0c;返回一个字符串数组 answer &#xff08;从 1 开始索引&#xff09;&#xff0c;其中&#xff1a; answer[i] “FizzBuzz” 如果 i 能被 3 和 5 整除。answer[i] “Fizz” 如果 i 能被 3 整除。answer[i]…

【gulp+jq+html】添加环境变量,并在js中使用(判断环境,更改api接口域名)+ 附gulpfile.js代码

参考博文&#xff1a; gulp分离环境 gulp中如何配置环境变量 gulp环境变量配置 1、安装cross-env插件 npm install cross-env -d2、package.json更改scripts "scripts": {"clean": "gulp clean","serve:test": "cross-env NODE…

IP协议(2) 和 数据链路层协议基础

IP协议续 1.路由选择 在复杂的网络结构中,我们需要找到一个通往终点的路线,这就是路由选择 举个例子:我们在没有手机导航之前,想去一个地方得是到一个地方问一下路的方式最终找到目的地 路由的过程,其实就是样子问路的过程 1.当IP数据包到达路由器的时候,会查看目的IP 2.路由器…

HAL库配置PWM模式

一、什么是PWM 脉冲宽度调制(PWM)&#xff0c;是英文“Pulse Width Modulation”的缩写&#xff0c;简称脉宽调制。通过控制高低电平在一个周期内的占比从而输出一定的电压。 向上计数原理介绍 ​PWM的一个周期 定时器从0开始向上计数 当0-t1段,定时器计数器TIMx_CNT值小于…

Springboot-前后端分离——第三篇(三层架构与控制反转(IOC)-依赖注入(DI)的学习)

本篇主要对ControllerServiceDAO三层结构以及控制反转&#xff08;IOC&#xff09;与DI&#xff08;依赖注入&#xff09;进行总结。 目录 一、三层架构&#xff1a; Controller/Service/DAO简介&#xff1a; 二、控制反转(IOC)-依赖注入(DI): 概念介绍&#xff1a; DOC与…

学校如何提升教学效率?这种方法要牢记!

随着教育信息化的发展&#xff0c;学校管理也逐渐借助先进的技术手段实现智能化、高效化。在线巡课系统作为其中的重要组成部分&#xff0c;为学校领导提供了便捷而有效的管理工具。 客户案例 中小学校长办公室 在中小学校长办公室&#xff0c;校长通过在线巡课系统可以实时查…

js 设置、获取、删除标签属性以及H5自定义属性

1. 设置标签属性 使用setAttribute()(‘属性名’, ‘属性值’)方法可以添加、修改、删除属性。   下面的demo是为input添加、修改、删除value属性&#xff1a; 1.1. HTML <input type"text" class"input"> <input type"text" class…

apk反编译修改教程系列---修改apk的默认颜色 布局颜色 手机电脑同步演示【十】

往期教程&#xff1a; apk反编译修改教程系列-----修改apk应用名称 任意修改名称 签名【一】 apk反编译修改教程系列-----任意修改apk版本号 版本名 防止自动更新【二】 apk反编译修改教程系列-----修改apk中的图片 任意更换apk桌面图片【三】 apk反编译修改教程系列---简单…

centos7 安装 java17 安装 idea

删除旧版本的java或者说是自带的&#xff0c;免得干扰 查找java [wanglcentos7 java]$ rpm -qa|grep javajava-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64 javapackages-tools-3.4.1-11.el7.noarch tzdata-java-2020a-1.el7.noarch python-javapackages-3.4.1-11.el7.noarch …

获取响应请求头里的信息

如图所示这是一个导出excel的接口&#xff0c;后端响应头部&#xff0c;要获取Content-Disposition里的值&#xff0c; 由于命名问题&#xff0c;没有办法用res.Content-Disposition的方式获取它的值 按理来说使用res[Content-Disposition]就可以获取到&#xff0c;但是咩有&…

MySql主从同步,同步SQL_ERROR 1032解决办法

1.登录从库 mysql -u root -p 2.输入命令查看状态 SHOW SLAVE STATUS\G; 3.找到对应的错误数据位置 Slave_IO_Running: YesSlave_SQL_Running: NoReplicate_Do_DB: app_push_centerReplicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Tabl…

【C++】vector的简单使用和实现

vector就是我们之前数据结构学的顺序表&#xff0c;这篇博客就是说一说它的简单使用和底层实现 文章目录 简单使用模拟实现 简单使用 首先&#xff0c;我们看看它的构造函数 我们比较常用的也就是第二种&#xff0c;就是第一个参数是要存的数据个数&#xff0c;第二个是要填…

Linux系统Shell脚本-----------正则表达式 文本三剑客之---------grep、 sed

一、正则表达式 1.前言 正则表达式(regular expression)描述了一种字符串匹配的模式&#xff08;pattern&#xff09;&#xff0c;可以用来检查一个串是否含有某种子串、将匹配的子串替换或者从某个串中取出符合某个条件的子串等。在Linux中也就是代表我们定义的模式模板&…

HAL库硬件SPI点亮板载LCD屏幕

1、本节内容介绍 1.1、HAL库硬件SPI 在cubemx中的配置及注意事项; 1.2、HAL库SPI详解与结构介绍; 1.3、实现硬件SPI驱动板载ST7789显示屏,240*240像素&#xff1b; 源码地址&#xff1a;https://gitee.com/MR_Wyf/hal-cubemx-rt-thread/tree/hal_rttNano_st7789_menu/ 或者…