zoukankan      html  css  js  c++  java
  • maven管理整理

    maven管理整理

    学习了:https://www.imooc.com/learn/443

    mvn -v      版本
        compile 编译
        test    测试
        package 打包
    
        clean   删除
        install 安装jar包到本地仓库
    
        创建目录的两种方式:
        1,archetype:generate 按照提示进行选择
        2,archetype:generate   -DgroupId=组织名,公司网址反写+项目名
                                -DartifactId=项目名-模块名
                                -Dversion=版本号
                                -Dpackage=包名
    
    镜像仓库
        
    pom.xml元素:
    project
    modelVersion    指定当前pom的版本
    groupId         反写的公司网址+项目名
    artifactId      项目名+模块名
    version         第一个0表示大版本号,第二个0表示分支版本号,第三个0表示小版本号
                    0.0.1-SNAPSHOT,alpha内部测试, beta公测, release稳定, GA
    packaging       默认是jar,还有war zip pom
    name            项目描述名
    url             项目地址
    description     项目描述
    developers      开发任意列表
    licenses        许可证信息
    organization    组织信息
    
    dependencies    依赖列表
        dependency      依赖项
            groupId
            artifactId  
            version
            type
            scope       test只在测试代码范围有用
            optional    true/false  设置依赖是否可选
            exclusions  排除依赖传递列表
                exclusion
    dependencyManagement    依赖管理,一般用于父模块
        dependencies        依赖列表
            dependency  
    build
        plugins 插件列表
            plugin  插件
                groupId
                artifactId
                version
    parent  子模块中对父模块的继承
    modules 多个子模块一起编译
    
    maven依赖范围   http://maven.apache.org/ compile/provided/runtime/test/system/import
    
    修改默认的maven编译等级,修改settings,增加profile
        <profile>
          <id>jdk-1.8</id>
          <activation>
            <activeByDefault>true</activeByDefault>
            <jdk>1.8</jdk>
          </activation>
          <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
          </properties>
        </profile>
    
    maven依赖:短路优先、先声明优先
    
    web项目:
        archetype  web-app
        pom中增加servlet
        junit 版本改为4.10
        创建source folder
        确保output
        project facets -> 选择动态模块
        deployment assembly -> 删除test/resources
        在build中加入jetty maven的插件 
        mvn build... 运行jetty:run
        可以指定package的时候运行

     pom:

    <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/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.imooc.webdemo</groupId>
        <artifactId>webdemo2</artifactId>
        <packaging>war</packaging>
        <version>0.0.1-SNAPSHOT</version>
        <name>webdemo2 Maven Webapp</name>
        <url>http://maven.apache.org</url>
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.10</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.0.1</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
        <build>
            <finalName>webdemo2</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <!-- 
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>8.1.16.v20140903</version>
                    resin这个还是有问题的
                    <groupId>com.caucho</groupId>
                    <artifactId>resin</artifactId>
                    <version>3.0.9</version>
                     -->
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>
  • 相关阅读:
    Unity在协程内部停止协程自身后代码执行问题
    unity如何停止不用字符串方式开启协程的方法
    解决导入protobuf源代码Unity报错的问题
    FastCGI模式编译安装LAMP+Xcache
    Apache配置防盗链
    Apache配置日志切割
    Apache配置参数的优化
    Apache三种工作模式详解
    隐藏Nginx、Apache、PHP的版本号
    配置Apache控制浏览器端的缓存的有效期
  • 原文地址:https://www.cnblogs.com/stono/p/9038595.html
Copyright © 2011-2022 走看看