zoukankan      html  css  js  c++  java
  • 一丢丢 Maven 笔记

    1、依赖配置和传递 dependencies

     <dependencies>
            <dependency>
                //包名
                <groupId>org.springframework.boot</groupId>
                //项目名
                <artifactId>spring-boot</artifactId>
                //版本号
                <version>2.3.7.RELEASE</version>
                //依赖范围【主程序范围有效:main文件夹内】【测试范围有效:test文件夹】【是否参与打包:package指令范围内】
                //默认compile
                <scope>compile / provided / test / runtime</scope>
                //可选依赖,默认false;为true时依赖不会传递,只在当前项目生效
                <optinal>true</optinal>
                //排除依赖,不需要指定版本号,涉及的依赖全都不要
                <exclusions>
                    <exclusion>
                        <groupId>com.alibaba</groupId>
                        <artifactId>fastjson</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    </dependencies>
    

    2、依赖范围 scope

    3、聚合 pom

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="http://maven.apache.org/POM/4.0.0"
             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>
    
        <groupId>org.example</groupId>
        <artifactId>Advanced</artifactId>    
        <version>1.0-SNAPSHOT</version>
        
        //定义该模块用于聚合
        <packaging>pom</packaging>
        
        <modules>
            <module>javaFXView</module>
            <module>upFile</module>
            <module>schedule</module>
        </modules>
    
        <properties>
            <maven.compiler.source>8</maven.compiler.source>
            <maven.compiler.target>8</maven.compiler.target>
        </properties>
    
    </project>
    

    4、继承,属性

    pom:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="http://maven.apache.org/POM/4.0.0"
             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>
    
        <groupId>org.example</groupId>
        <artifactId>Advanced</artifactId>    
        <version>1.0-SNAPSHOT</version>
        
        //定义该模块用于聚合
        <packaging>pom</packaging>
        
        <modules>
            <module>javaFXView</module>
        </modules>
    
        //属性
        <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.3.7.RELEASE</spring-boot.version>
    
        </properties>
        
        //统一管理版本
        <dependencyManagement>
             <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot</artifactId>
                <version>${spring-boot.version}</version>
            </dependency>
        </dependencies>
        </dependencyManagement>
    </project>
    

    pom-son1:

        <parent>
           <groupId>org.example</groupId>
            <artifactId>Advanced</artifactId>    
            <version>1.0-SNAPSHOT</version>
        </parent>
    
        <properties>
            <java.version>1.8</java.version>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot</artifactId>
            </dependency>
        </dependencies>
    

    5、版本管理

    • 快照版本—SNAPSHOT

      随时会改

    • 发布版本—RELEASE

      成品

    约定规范

    示例:5.1.9.RELEASE

    • 主版本.次版本.增量版本.里程碑版本
    • 主:项目重大架构变更
    • 次:功能改变,或者全面系统地修复漏洞
    • 增量:重大漏洞修复
    • 里程碑:快照版本、发布版本

    6、资源配置

    pom:

     
        <properties>
            <maven.compiler.source>8</maven.compiler.source>
            <maven.compiler.target>8</maven.compiler.target>
            <jdbc.url>jdbc:mysql://192.168.15.129:3306/shiro?useUnicode=true&amp;characterEncoding=utf8&amp;autoReconnect=true&amp;failOverReadOnly=false</jdbc.url>
        </properties>
    
       <build>
            <resources>
                <resource>
                    <directory>${project.basedir}/src/main</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
    
            <testResources>
                <testResource>
                    <directory>${project.basedir}/src/main/resource</directory>
                    <filtering>true</filtering>
                </testResource>
            </testResources>
        </build>
    

    jdbc.properties:

    jdbc.url=${jdbc.url}
    jdbc.class=com.mysql.cj.jdbc.Driver;
    jdbc.username=root
    jdbc.password=123456
    

    7、多环境配置

    pom:

        //创建多环境
        <profiles>
            //开发环境
            <profile>
                <id>dev</id>
                <properties>
                    <jdbc.url>${jdbc.url}</jdbc.url>
                </properties>
                //设为默认启动
                <activation>
                    <activeByDefault>true</activeByDefault>
                </activation>
            </profile>
    
            //生产环境
            <profile>
                <id>pev</id>
                <properties>
                    <jdbc.url>jdbc:mysql://192.168.15.129:3306</jdbc.url>
                </properties>
            </profile>
        </profiles>
    

    mvn 启动命令

    mvn install -P dev

    mvn install -P pev

    nexus 私服

    Nexus私服

  • 相关阅读:
    判断字符串和null相等 if(keyword.equals("null"))
    去掉input text后面的叉
    设置标题小图标ico
    使用onclick跳转到其他页面。使用button跳转到指定url
    中文输入法不触发onkeyup事件的解决办法
    全选js实现
    修改数据库结构需要修改的部分
    1. 移动测试点
    2.7.2 元素定位:frame 内定位 driver.switch_to.frame()
    2.7.1 元素定位:selenium消息框处理 (alert、confirm、prompt)
  • 原文地址:https://www.cnblogs.com/qqkkOvO/p/15619856.html
Copyright © 2011-2022 走看看