springmvc+mybatis+maven项目框架搭建

项目的目录

 

 

1.配置web.xml

 

复制代码
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>teaboy</display-name>


    <!-- 设置路径变量值 -->
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

    <!-- 日志配置文件路径结束 -->


    <!-- spring字符集过滤器开始 -->
    <filter>
        <filter-name>setCharacterEncoding</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>setCharacterEncoding</filter-name>
        <url-pattern>/</url-pattern>
    </filter-mapping>
    <!-- spring字符集过滤器结束 -->

    <!--spring MVC核心配置开始 -->
    <servlet>
        <servlet-name>teaboy</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:conf/core/project-tea-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>teaboy</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <!--spring MVC核心配置结束 -->

    <!-- Spring 刷新Introspector防止内存泄露 -->
    <listener>
        <listener-class>
            org.springframework.web.util.IntrospectorCleanupListener</listener-class>
    </listener>

    <!-- 支持session scope的Spring bean -->
    <listener>
        <listener-class>
            org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>

    <!-- filter 过滤器 权限控制 -->
    <!-- <filter> <filter-name>PermissionFilter</filter-name> <filter-class>com.elong.ihotelms.web.filter.PermissionFilter</filter-class> 
        </filter> <filter-mapping> <filter-name>PermissionFilter</filter-name> <url-pattern>/*</url-pattern> 
        </filter-mapping> -->

    <!-- 设置超时时间 30分钟 -->
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>

</web-app>
复制代码

 

2.maven pom.xml配置:

 

复制代码
<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.teaboy</groupId>
    <artifactId>teaboy</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>teaboy Maven Webapp</name>
    <url>http://maven.apache.org</url>


    <properties>
        <!-- spring版本号 -->
        <spring.version>3.2.4.RELEASE</spring.version>
        <!-- mybatis版本号 -->
        <mybatis.version>3.2.4</mybatis.version>
        <!-- log4j日志文件管理包版本 -->
        <slf4j.version>1.6.6</slf4j.version>
        <log4j.version>1.2.9</log4j.version>
    </properties>



    <build>
        <finalName>${project.artifactId}</finalName>
        <!--指定maven的操作是install -->
        <defaultGoal>install</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.9</version>
                <!-- 跳过单元测试 -->
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
            </plugin>
            <!-- 是否下载源码 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                </configuration>
            </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.8.1</version>
            </plugin>
        </plugins>

    </build>


    <dependencies>
        <!-- junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>

        <!--fastJson -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.1.39</version>
        </dependency>


        <!-- google 集合工具类 -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>

        <!-- 文件监控框架 -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.7.0</version>
        </dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.8.7</version>
        </dependency>

        <dependency>
            <groupId>aopalliance</groupId>
            <artifactId>aopalliance</artifactId>
            <version>1.0</version>
        </dependency>
        <!-- 解决找不到 jacksonMessageConverter 问题-->
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.4</version>
        </dependency>

        <!-- spring核心包 -->
        <!-- springframe start -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</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-oxm</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-jdbc</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-context-support</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- springframe end -->

        <!-- mybatis核心包 -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>${mybatis.version}</version>
        </dependency>
        <!-- mybatis/spring包 -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>1.2.2</version>
        </dependency>
        <!-- mysql驱动包 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.29</version>
        </dependency>


        <!-- 阿里巴巴数据源包 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.2</version>
        </dependency>

        <!--数据源 -->
        <!-- <dependency> <groupId>org.logicalcobwebs</groupId> <artifactId>proxool</artifactId> 
            <version>0.9.1</version> </dependency> <dependency> <groupId>org.logicalcobwebs</groupId> 
            <artifactId>proxool-cglib</artifactId> <version>0.9.1</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 -->

        <!-- 工具类包,DateUtil,StringUtil -->
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
            <scope>provided</scope>
        </dependency>


        <!-- rabitMq -->
        <dependency>
            <groupId>com.rabbitmq</groupId>
            <artifactId>amqp-client</artifactId>
            <version>3.0.4</version>
        </dependency>
        <!-- jedis -->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.4.2</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.2</version>
        </dependency>


        <!--数据源 -->
        <dependency>
            <groupId>proxool</groupId>
            <artifactId>proxool</artifactId>
            <version>0.9.1</version>
        </dependency>

        <dependency>
            <groupId>proxool</groupId>
            <artifactId>proxool-cglib</artifactId>
            <version>0.9.1</version>
        </dependency>

    </dependencies>


</project>
复制代码

 

3.spring project-tea-servlet.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" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:oscache="http://www.springmodules.org/schema/oscache"
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
           http://www.springmodules.org/schema/oscache http://www.springmodules.org/schema/cache/springmodules-oscache.xsd
           http://code.alibabatech.com/schema/dubbo
              http://code.alibabatech.com/schema/dubbo/dubbo.xsd">


    <!-- 以下一行配置为JavaDoc站点,必须保留!!!切记!!!如果更改或servlet.xml,请务必保留下行 -->
    <mvc:annotation-driven/>
    <context:component-scan base-package="com.teaboy" />
    <!-- 声明自动为spring容器中那些配置@aspectJ切面的bean创建代理,织入切面。 -->
    <aop:aspectj-autoproxy />

    <mvc:resources mapping="/apidocs/**" location="/apidocs/" />
    <mvc:resources mapping="/hc/**" location="/hc/" />

    <!-- Spring 初始化bean的容器 -->
    <bean id="springContextHolder" class="com.teaboy.util.SpringWebContextHolder" />




    <!-- HttpAPI日志拦截器,完成对@ResponseBody注解的Http请求 -->
    <!-- <bean id="serviceAspect" class="com.elong.springmvc_enhance.core.ServiceAspect"> 
        </bean> <aop:config> <aop:pointcut id="si" expression="@annotation(org.springframework.web.bind.annotation.ResponseBody)" 
        /> <aop:advisor pointcut-ref="si" advice-ref="serviceAspect" /> </aop:config> 
        页面全局异常处理 <bean id="exceptionResolver" class="com.elong.springmvc_enhance.core.HotelHandlerExceptionResolver"> 
        </bean> -->
         
    <!-- spring拦截器 -->  
    <mvc:interceptors>  
        <bean class="com.teaboy.web.filter.SpringMvcInterceptor" />  
    </mvc:interceptors>  



    <!--前置处理器添加消息转化器 -->
    <bean class="com.teaboy.web.filter.UTFStringHttpMessage" />


    <!-- 避免IE在ajax请求时,返回json出现下载 -->
    <bean id="jacksonMessageConverter"
        class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>text/html;charset=UTF-8</value>
            </list>
        </property>
    </bean>


    <!--数据库配置 -->
    <import resource="classpath:conf/core/database.xml" />

    <!-- cache 引用 -->
    <!-- <import resource="classpath:conf/core/cache.xml" /> -->

    <!-- thread pool -->
<!--     <import resource="classpath:conf/core/service.xml" /> -->
</beans>
复制代码

 

4.log4j.properties配置:

 

复制代码
### set log levels ###
#log4j.rootLogger = debug , stdout , D , E
log4j.rootLogger = debug , stdout , D
 
###  output to the console ###
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern = %d{ABSOLUTE} %5p %c{ 1 }:%L - %m%n
log4j.appender.stdout.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n
 
### Output to the log file ###
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = ${teaboy.root}/WEB-INF/logs/log.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = DEBUG 
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
 
### Save exception information to separate file ###
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = ${teaboy.root}/WEB-INF/logs/error.log 
log4j.appender.D.Append = true
log4j.appender.D.Threshold = ERROR 
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
复制代码

 

5.database.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" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <!--数据源配置 -->
    <context:property-placeholder
        location="classpath:conf/custom/env/jdbc.properties"
        ignore-unresolvable="true" />

    <!--数据源 读写 -->
    <bean id="dataSourceRW" class="com.teaboy.dao.datasource.ExtendsProxoolDataSource">
        <property name="alias" value="dataSourceRW"></property>
        <property name="delegateProperties">
            <value>user=${jdbc_tea.username},password=${jdbc_tea.password}
            </value>
        </property>
        <property name="user" value="${jdbc_tea.username}" />
        <property name="password" value="${jdbc_tea.password}" />
        <property name="driver" value="${jdbc_tea.driverClassName}" />
        <property name="driverUrl" value="${jdbc_tea.url}" />
        <property name="maximumConnectionCount" value="${jdbc_tea.maximumConnectionCount}"></property>
        <property name="maximumActiveTime" value="${jdbc_tea.maximumActiveTime}"></property>
        <property name="maximumConnectionLifetime" value="${jdbc_tea.maximumConnectionLifetime}"></property>
        <property name="prototypeCount" value="${jdbc_tea.prototypeCount}"></property>
        <property name="houseKeepingSleepTime" value="${jdbc_tea.houseKeepingSleepTime}"></property>
        <property name="simultaneousBuildThrottle" value="${jdbc_tea.simultaneousBuildThrottle}"></property>
        <property name="houseKeepingTestSql" value="${jdbc_tea.houseKeepingTestSql}"></property>
        <property name="verbose" value="${jdbc_tea.verbose}"></property>
        <property name="statistics" value="${jdbc_tea.statistics}"></property>
        <property name="statisticsLogLevel" value="${jdbc_tea.statisticsLogLevel}"></property>
    </bean>
    
       <!--数据源 读-->
    <bean id="dataSourceR" class="com.teaboy.dao.datasource.ExtendsProxoolDataSource">
        <property name="alias" value="dataSourceR"></property>
        <property name="delegateProperties">
            <value>user=${jdbc_tea.r.username},password=${jdbc_tea.r.password}
            </value>
        </property>
        <property name="user" value="${jdbc_tea.r.username}" />
        <property name="password" value="${jdbc_tea.r.password}" />
        <property name="driver" value="${jdbc_tea.r.driverClassName}" />
        <property name="driverUrl" value="${jdbc_tea.r.url}" />
        <property name="maximumConnectionCount" value="${jdbc_tea.maximumConnectionCount}"></property>
        <property name="maximumActiveTime" value="${jdbc_tea.maximumActiveTime}"></property>
        <property name="maximumConnectionLifetime" value="${jdbc_tea.maximumConnectionLifetime}"></property>
        <property name="prototypeCount" value="${jdbc_tea.prototypeCount}"></property>
        <property name="houseKeepingSleepTime" value="${jdbc_tea.houseKeepingSleepTime}"></property>
        <property name="simultaneousBuildThrottle" value="${jdbc_tea.simultaneousBuildThrottle}"></property>
        <property name="houseKeepingTestSql" value="${jdbc_tea.houseKeepingTestSql}"></property>
        <property name="verbose" value="${jdbc_tea.verbose}"></property>
        <property name="statistics" value="${jdbc_tea.statistics}"></property>
        <property name="statisticsLogLevel" value="${jdbc_tea.statisticsLogLevel}"></property>
    </bean>
    
    <!-- 动态数据源 -->
    <bean id="dynamicDataSource" class="com.teaboy.dao.datasource.DynamicDataSource">
        <!-- 通过key-value关联数据源 -->
        <property name="targetDataSources">
            <map>
                <entry value-ref="dataSourceRW" key="dataSourceRW"></entry>
                <entry value-ref="dataSourceR" key="dataSourceR"></entry>
            </map>
        </property>
        <!-- 默认数据源为读写库(主库)数据源 -->
        <property name="defaultTargetDataSource" ref="dataSourceRW" />    
    </bean>

    <!--mybatis与Spring整合 开始 -->
    <bean id="paginationInterceptor" class="com.teaboy.dao.pagination.PaginationInterceptor">
        <property name="dialect">
            <bean class="com.teaboy.dao.pagination.dialect.MySQLDialect" />
        </property>
        <property name="paginationSqlRegEx" value=".*ByCond"></property>
    </bean>
    <bean id="sqlSessionFactory" name="sqlSessionFactory"
        class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="configLocation" value="classpath:conf/core/sqlMapConfig.xml" />
        <property name="dataSource" ref="dynamicDataSource" />
        <property name="plugins">
            <array>
                <ref bean="paginationInterceptor" />
            </array>
        </property>
    </bean>
    
    <!--mybatis与Spring整合 结束 -->

    <!-- 事务管理器配置,单数据源事务 -->
    <tx:annotation-driven transaction-manager="omsTransactionManager" />
    <bean id="omsTransactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSourceRW" />
    </bean>
    <tx:advice id="omsDefaultTxAdvice" transaction-manager="omsTransactionManager">
        <tx:attributes>
            <tx:method name="find*" propagation="SUPPORTS"
                rollback-for="java.lang.Exception" />
            <tx:method name="query*" propagation="SUPPORTS"
                rollback-for="java.lang.Exception" />

            <tx:method name="*" rollback-for="java.lang.Exception" />
        </tx:attributes>
    </tx:advice>
<!--     <aop:config>
        <aop:pointcut id="omsServiceOperations"
            expression="execution(* com.elong.train.service.oms..*Service.*(..))" />
        <aop:advisor advice-ref="omsDefaultTxAdvice" pointcut-ref="omsServiceOperations" />
    </aop:config> -->
    
    <!-- 事务配置结束 -->
</beans>
复制代码

 

6.sqlMapConfig.xml 配置:

 

复制代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

    <typeAliases>
        <!-- <typeAlias type="com.teaboy.model.IhotelActivityDetailBind" alias="IhotelActivityDetailBind"/> -->
        
    </typeAliases>
    <mappers>
        <!-- 查询F码绑定 -->
        <!-- <mapper resource="conf/mybatis/ihotelActivityDetailBind.xml"/> -->
    </mappers>
</configuration>
复制代码

 

7.jdbc.properties配置

复制代码
jdbc_tea.driverClassName=com.mysql.jdbc.Driver



jdbc_tea.url=jdbc\:mysql\://192.168.73.15\:6015/XXXX?zeroDateTimeBehavior\=convertToNull
jdbc_tea.username=liangyong.guo
jdbc_tea.password=123456

jdbc_tea.maximumConnectionCount=100
jdbc_tea.maximumActiveTime=3600000
jdbc_tea.maximumConnectionLifetime=3600000
jdbc_tea.prototypeCount=5
jdbc_tea.houseKeepingSleepTime=30000
jdbc_tea.houseKeepingTestSql=select now()
jdbc_tea.simultaneousBuildThrottle=50
jdbc_tea.verbose=true
jdbc_tea.statistics=10s,1m,1d
jdbc_tea.statisticsLogLevel=ERROR
复制代码

 

8.setting.xml配置

复制代码
<?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>/Users/user/.m2/lp_tea/repository</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>
            <id>optional</id>
            <active>true</active>
            <protocol>http</protocol>
            <host>127.0.0.1</host>
            <port>8087</port>
        </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 | 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>nexus-osc</id>
            <mirrorOf>*</mirrorOf>
            <name>Nexus osc</name>
            <url>http://maven.oschina.net/content/groups/public/</url>
        </mirror>

    </mirrors>

    <!-- 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>nexus</id>
                        <name>local private nexus</name>
                        <url>http://maven.oschina.net/content/groups/public/</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>false</enabled>
                        </snapshots>
                    </repository>
                </repositories>
                <pluginRepositories>
                    <pluginRepository>
                        <id>nexus</id>
                        <name>local private nexus</name>
                        <url>http://maven.oschina.net/content/groups/public/</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>false</enabled>
                        </snapshots>
                    </pluginRepository>
                </pluginRepositories>
            </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>
复制代码

 搭建成功:

 

 

搭建的过程中碰到很多问题,慢慢的解决了,没有解决不了的问题。。。。

 

posted @ 2021-12-24 15:36  hanease  阅读(33)  评论(0编辑  收藏  举报