Maven高级


Maven高级

1.maven基础回顾

2.maven传统的web工程做一个数据查询操作

3.maven工程拆分与聚会的思想

4.把第二阶段做好的web工程修改成maven拆分与聚合的形式

5.私服【远程仓库】

6.任何安装第三方jar包【把第三方jar包安装到本地仓库,把第三方jar包安装到私服。】

maven基础知识回顾:
maven是一一个项目管理工具。
  • 依赖管理:maven对项目中jar包的管理过程。传统工程我们直接把jar包放置在项目中。maven工程真正的jar包放置在仓库中,项目中只用放置jar包的坐标。

  • 仓库的种类:本地仓库,远程仓库[私服],中央仓库。

  • 仓库之间的关系:当我们启动一个maven工程的时候,maven工程会通过pom文件中jar包的坐标去本地仓库找对默认情况下,如果本地仓库没有对应jar包,maven.工程会自动去中央仓库下载jar包到本地,在公司中,如果本地没有对应jar包,会先从私服下载jar包,如果私服没有jar包,可以从中央仓库下载,也可以从本地上传。

  • 一键构建: maven自身集成了tomcat插件,可以对项目进行编译,测试,打包,安装,发布等操作。

  • maven常用命令: clean, compile, test, package, insta1l, deploy。

  • maven三套生命周期:清理生命周期,默认生命周期,站点生命周期。

web.xml配置头:

<web-app xmlns="http://java. sun. com/xml/ns/javaee"
         xmlns :xsi="http://www. W3. org/ 2001/XMLSchema- instance"
         xsi : schemalocation= "http://java. sun. com/ xml/ns/javaee
         http://java. sun. com/ xm1/ns/javaee/web-app 3_ 0.xsd"
         version="3.0">

maven导入jar包的冲突问题:

<!-- maven工程要导入jar包的坐标, 就必须考虑解决jar包冲突。
        解决jar包冲突的方式一^:
        第一优先声明原则,哪个jar包的坐标在靠上的位置,这个jar包就是先声明的。
        先声明的jar包坐标下的依赖包,可以优先进入项目中。
        
        maven导入jar包中的一-些 概念:
        直接依赖:项目中直接导入的jar包,就是该项目的直接依赖包
        传递依赖:项目中没有直接导入的jar包,可以通过项目直接依赖jar包传递到项目中去
        
        解决jar包冲突的方式二
        路径近者优先原则。直接依赖路径比传递路径近,那么最终项目进入的jar包会是路径近的直接依赖包:
        
        解决jar包冲突的方式三: [推荐使用] :
        直接排除法。
        当我们要排除某个jar包下的依赖包,在配置exclusions标签的时候,内部可以不写版本号。
        因为此时依赖包使用的版本和默认版本jar包一样。
-->
<!-- maven工程要导入jar包的坐标, 就必须考虑解决jar包冲突。
        解决jar包冲突的方式:
        第一优先声明原则,哪个jar包的坐标在靠上的位置,这个jar包就是先声明的。
        先声明的jar包坐标下的依赖包,可以优先进入项目中。
        
        maven导入jar包中的一-些 概念:
        直接依赖:项目中直接导入的jar包,就是该项目的直接依赖包
        传递依赖:项目中没有直接导入的jar包,可以通过项目直接依赖jar包传递到项目中去
        
        解决jar包冲突的方式: :
        路径近者优先原则。直接依赖路径比传递路径近,那么最终项目进入的jar包会是路径近的直接依赖包。
        
        解决jar包冲突的方式三: [推荐使用] :
        直接排除法。
        当我们要排除某个jar包下的依赖包,在配置exclusions标签的时候,内部可以不写版本号。
        因为此时依赖包使用的版本和默认版本jar包样。
-->

完整的mvc架构全部坐标:

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.itheima</groupId>
  <artifactId>maven_day02_1</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <properties>
    <spring.version>5.0.2.RELEASE</spring.version>
    <slf4j.version>1.6.6</slf4j.version>
    <log4j.version>1.2.12</log4j.version>
    <shiro.version>1.2.3</shiro.version>
    <mysql.version>8.0.17</mysql.version>
    <mybatis.version>3.4.5</mybatis.version>
    <spring.security.version>5.0.1.RELEASE</spring.security.version>
  </properties>
  
  <!-- 锁定jar包版本 -->
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${spring.version}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
      </dependency>
      <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis</artifactId>
        <version>${mybatis.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <!-- 项目依赖jar包 -->
  <dependencies>
    <!-- spring -->
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
      <version>1.6.8</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aop</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context-support</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>${mysql.version}</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>jstl</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
    <!-- log start -->
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>${log4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <!-- log end -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>${mybatis.version}</version>
    </dependency>
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>1.3.0</version>
    </dependency>
    <dependency>
      <groupId>c3p0</groupId>
      <artifactId>c3p0</artifactId>
      <version>0.9.1.2</version>
      <type>jar</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.github.pagehelper</groupId>
      <artifactId>pagehelper</artifactId>
      <version>5.1.2</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-web</artifactId>
      <version>${spring.security.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-config</artifactId>
      <version>${spring.security.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-core</artifactId>
      <version>${spring.security.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-taglibs</artifactId>
      <version>${spring.security.version}</version>
    </dependency>
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid</artifactId>
      <version>1.0.9</version>
    </dependency>
  </dependencies>
</project>

dao层的编写:

(1):配置文件的书写:
<!-- dao层配置文件开始-->
<!-- 配置连接池-->
<bean id="dataSource" class="com. alibaba。druid。pool . DruidDataSource">
    <property name =”driverClassName" value="com.mysql.cj.jdbc.Driver"/>
    <property name "url" value=" jdbc :mysql://localhost :3306/maven?serverTimezone=UTC" />
    <property name="username" value= "root" />
    <property name=" password" value= ”xzq1314"/> 
</bean>

<!-- 配置SqlSession对象的工厂 -->
<bean id= ”sqlSessionFactoryBean" class= "org.mybatis.spring.SqlSessionFactoryBean"> 
    <property name="datasource" ref="dataSource"/> 
    <!--扫描pojo包,给包下所有pojo对象起别名-->
    <property name= ”typeAliasesPackage" value=" com . itheima . damain"/>
</bean>

<!--扫描接口包路径,生成包下所有接口的代理对象,并且放入spring容器中-->
<bean class= ”org.mybatis.spring.mapper.MapperSc annerConfigurer"> 
<property name= ”basePackage" value= "com.itheima.dao" />
</bean>
<!-- dao层配置文件结束-->
(2):书写dao层:
import com.itheima.damain.Items ;
public interface ItemsDao {

        public Items findById(Integer id);
}
由于交给了spring容器管理,所以不需要写dao接口的实现类。

(3):service层的配置:

<!-- service层配置文件开始-->

<!-- 组件打描配置-->
<context : component-scan base-package="com.itheima.service" />

<!-- aop面向切面编程,切面就是切入点和通知(就是增强类)的组合-->

<!-- 配置事务管理器-- >
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="datasource" ref= "dataSource"/>
</bean> 

<!-- 配置事务的通知-->
<tx:advice id=" advice">
    <tx:attr ibutes>
        <tx :method name= ”save*" propagation="REQUIRED"/>
        <tx : method name= "update*" propagation="REQUIRED"/>
        <tx : method name="delete" propagat ion= "REQUIRED" />
        <tx : method name="find*" read-only="true" />
        <tx:method name= ”*”propagation="REQUIRED" />
    </tx:attributes>
</tx: advice>

<!-- 配置切面-->
<aop:config>
    <aop:pointcut id="pointcut" expression="execution(* com.itheima.service.imp1.*.*(..))"/>
    <!-- advice-ref通知类pointcut-ref 切入点 -->
    <aop:advisor advice- ref="advice" pointcut-ref="pointcut" />
</aop:config>
<!-- service层配置文件结束-->

(4):service层的编写

public interface ItemsService {

    public Items findById(Integer id);
    
}
import com.itheima.damain.Items ;
import com.itheima.dao.ItemsDao;
import com.itheima.service.ItemsService;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service;

@Service
public class ItemsServiceImpl implements ItemsService {

    @Autowired
    private ItemsDao itemsDao ;
    
    public Items findById(Integer id) {
        return itemsDao. findById(id);
    }
}
dao层自动注入注解:@Autowired

(5):web层的配置:

配置两个xml文件:applicationContext.xml 和 springmvc.xml
(applicationContext.xml之前以及配好了)
springmvc.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/ schema/ beans"
       xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
       xmIns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop 
       xmIns:tx="http://www.springframework.org/schema/tx"
       xmIns:mvc="http://www.springframework.org/schema/mvc”
       xsi:schemaLocation-"http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/springbeans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring -tx.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring mvc .xsd"> 
       
        <!-- 组件扫描-->
        <context:component-scan base-package=”com.itheima.controller"/>
        
        <!-- 处理器映射器,处理器适配器-- >
        <mvc:annotation driven/>
        
        <!-- 视图解析器-- >
        <bean id=”internalResourceViewResolver" class= ”org.springframework.web.servlet.view.InternalResourceViewResolver">
        <!-- 前缀 -->
        <property name= ”prefix" value =”/WEB-INF/pages/"/>
        <!--后缀-->
        <property name = "suffix" value=".jsp"/>
    </bean>
    
    <!-- 释放静态资源-->
    <mvc:default-servlet-handler/>
</beans> 

index.jsp


    

Controller类:

@Controller
@RequestMapping("/items”)
public class ItemsController {

    @Autowired
    private ItemsService itemsService;
    
    @RequestMapping("/findDetail")
    public string findDetail(Model model){
        Items items = itemsService.findById(1);
        model.addAttribute("item",items);    
        return” itemDetail";
    }
}

Maven的拆分以及聚合:

imaven解决代码可冲用和便于维护问题上是这么解决的:

maven把一个完整的项目,分成不同的独立模块,这些模块都有各自独立的坐标。哪个地方需要其中某个模块,就直接引用该模块的坐标即可。今后如果公司开发一个新项目, 我们先考虑问题不是dao, service, utils, domain如何编写 ,我们要考虑的是,dao, service, utils, domain这些模块是否已经存在,如果存在直接引用。以上说的就是maven拆分的思想。我们可以把拆分零散的模块聚合到一起编写-一个完整的项目,这就是maven聚合思想。
<!--工程和模块的区别:
    工程不等于完整的项目,模块也不等于完整的项目,-.个完整的项目看的是代码,代码完整,就可以说是一个完整的项目。
    和此项目是工程还是模块没有关系。
    工程天生只能使用自己内部资源,工程天生是独立的。后天可以和其他工程或模块建立关联关系。
    模块天生不是独立的,模块天生是属于父工程的。模块一旦创建,所有父工程的资源都可以使用。
    父子工程之间,子工程天生继承父工程。可以使用父工程所有资源。
    子模块之间天生是没有任何关系的。
    父子工程直接不用建立关系,继承关系是先天的,不需要手动建立。
    平极之间的引用叫依赖。依赖不是先天的,依赖是需要后天建立的。
-->

私服:

给私服传代码,先登录私服

        <mirror>
            <id>uk</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>http://uk.maven.org/maven2/</url>
        </mirror>
        <mirror>
            <id>CN</id>
            <name>OSChina Central</name>
            <url>http://maven.oschina.net/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.home}/conf/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <localRepository>D:/work/maven_work/maven_respository</localRepository>

  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>

        <mirror>
            <id>nexus-aliyun</id>
            <mirrorOf>*</mirrorOf>
            <name>Nexus aliyun</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
        </mirror>
    
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
  </mirrors>

  <profiles>
         <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>
  </profiles>

  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a system property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->

    <!--
     | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
     | might hypothetically look like:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
  </profiles>

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
</settings>
<!--  锁定版本信息  -->
  <properties>
    <!--  spring相关版本  -->
    <spring.version>5.2.8.RELEASE</spring.version>
    <!--  mybatis版本  -->
    <mybatis.version>3.5.5</mybatis.version>
    <!--  mybatis-spring版本  -->
    <mybatis-spring.version>2.0.5</mybatis-spring.version>
    <!--  mysql版本  -->
    <mysql.version>8.0.19</mysql.version>
    <!--  fast json版本  -->
    <fast-json.version>1.2.73</fast-json.version>
    <!--  jackson版本  -->
    <jackson.version>2.11.2</jackson.version>
  </properties>
  <!--  依赖坐标  -->
  <dependencies>
    <!-- spring相关 -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
      <version>1.8.7</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <!-- mybatis相关 -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>${mybatis.version}</version>
    </dependency>
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>${mybatis-spring.version}</version>
    </dependency>
    <!--  mysql  -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>${mysql.version}</version>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.2</version>
    </dependency>
    <!--  DBCP数据源  -->
    <dependency>
      <groupId>commons-dbcp</groupId>
      <artifactId>commons-dbcp</artifactId>
      <version>1.4</version>
    </dependency>
    <!--  log4j  -->
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.17</version>
    </dependency>
    <!--  单元测试  -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13</version>
      <scope>test</scope>
    </dependency>
    <!--  spring web  -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <!--  spring mvc  -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <!--  jsp  -->
    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.2</version>
      <scope>provided</scope>
    </dependency>
    <!--  servlet  -->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>4.0.1</version>
      <scope>provided</scope>
    </dependency>
    <!--  JSR 303依赖  -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>5.4.3.Final</version>
    </dependency>
    <!--  fast json  -->
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>fastjson</artifactId>
      <version>${fast-json.version}</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>${jackson.version}</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${jackson.version}</version>
    </dependency>
    <!--  commons-io  -->
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.7</version>
    </dependency>
    <!--  commons-fileupload  -->
    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
      <version>1.4</version>
    </dependency>
    <!--  shiro  -->
    <dependency>
      <groupId>org.apache.shiro</groupId>
      <artifactId>shiro-core</artifactId>
      <version>1.6.0</version>
    </dependency>
    <dependency>
      <groupId>jstl</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
    <!--  pagehelper  -->
    <dependency>
      <groupId>com.github.pagehelper</groupId>
      <artifactId>pagehelper</artifactId>
      <version>5.2.0</version>
    </dependency>
  </dependencies>

文章作者:
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 !
  目录