springmvc+mybatis+maven项目框架搭建

2023-10-30

项目的目录

 

 

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>

 搭建成功:

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

springmvc+mybatis+maven项目框架搭建 的相关文章

  • 使用SimpleMailMessage类发送邮件时如何使java字符串着色

    我正在使用 java 中的 SimpleMailMessage 类发送邮件 我将 spring 与 hibernate 结合使用 我想在发送邮件时将特定字符串设置为彩色 Code String emailBody Dear username
  • 编译错误:Android Studio

    我正在尝试修改基于 IntelliJ 构建的现有 Android 项目 我已经搜索并尝试了很多东西 但我的错误仍然没有消失 Error 5 1 android apt compiler main D android tinynote app
  • 定制法国号码格式

    我尝试为美国国家 地区使用自定义数字格式 到目前为止效果很好 Not something I want NumberFormat numberFormat0 NumberFormat getNumberInstance Locale US
  • 修复 java 内存泄漏的学习网站

    学习修复 java 内存泄漏的最佳地点是什么 我一直试图在网络上找到好的资源 但令我失望的是 我发现正在讨论玩具示例 我还能够对小型玩具转储进行故障排除 但现实世界的应用程序转储更具挑战性 并且提供的线索很少 我尝试过 Jhat JMap
  • 为移动设备扩展 libgdx UI?

    眼下desktop应用程序的版本很好 按钮缩放得很好 但是当我部署到android它们很小 几乎无法使用 DesktopLauncher public class DesktopLauncher public static void mai
  • mvn dependency:analyze 结果不正确

    我一直在寻找一种工具 它能够向您显示未使用的依赖项 我很快就偶然发现了 Maven 命令mvn dependency analyze 这样做的问题是 它经常检测到 未使用的 依赖项 如果缺失 这些依赖项就会导致构建失败 这是优化项目的示例
  • 仅使用 ServletContext 查找应用程序的 URL

    我正在使用 Spring MVC 编写一个 Java Web 应用程序 我有一个后台进程 它会遍历数据库并查找必须通过电子邮件发送给我的用户的通知 这些电子邮件需要包含应用程序的超链接 对于网络应用程序来说 这似乎是相当常见的模式 但我遇到
  • 如何在Spring Security SAML示例中配置IDP元数据和SP元数据?

    我想处理 Spring Security SAML 为此 我开始探索Spring安全SAML http docs spring io spring security saml docs 1 0 x reference html chapte
  • 如何在 Android 中将 EditText 绘制到画布上?

    我想画画 EditText username new EditText context 到我画布上的特定位置 protected void onDraw Canvas canvas 是否可以在基础上画出x y在我的 Java 文件中协调而不
  • 如何用java对jpg进行像素化?

    我正在尝试使用 Java 6 对 JPEG 进行像素化 但运气不佳 它需要使用 Java 而不是像 Photoshop 这样的图像处理程序 并且它需要看起来像老派 像这样 有谁能够帮助我 使用java awt image javadoc h
  • 在 Android 中使用 lambdaj

    有人尝试过在android开发中使用lambdaj库吗 当我创建一个简单的小型java应用程序时 它对我来说工作得很好 但我无法在android应用程序中使用它 UPDATE 我正在添加 lambdaj lambdaj 2 3 2 with
  • java3d 中的面部着色

    使用java3d 如何不在每个顶点基础上着色 而是在每个面基础上着色 我尝试学习 java3d 但我生成的 Shape3d 看起来并不符合预期 我想用不同的颜色给不同的三角形着色 但我不知道该怎么做 纹理看起来有点大材小用 而且我根本没有掌
  • SOAP Web 服务中的用户身份验证

    我提出了一个关于JAX WS 身份验证和授权 如何 https stackoverflow com questions 5314782 jax ws authentication and authorization how to 讨论了安全
  • Java反序列化中避免重复对象

    我有两个列表 list1 和 list2 其中包含对某些对象的引用 其中某些列表条目可能指向同一对象 然后 由于各种原因 我将这些列表序列化为两个单独的文件 最后 当我反序列化列表时 我想确保我不会重新创建超出需要的对象 换句话说 List
  • 如何迭代SparseArray?

    有没有办法迭代 Java SparseArray 适用于 Android 我用了sparsearray通过索引轻松获取值 我找不到 看来我找到了解决方案 我没有正确注意到keyAt index 功能 所以我会这样做 for int i 0
  • 如何将我的自定义相机应用程序设置为默认应用程序?

    如果我使用以下代码 Intent takePictureIntent new Intent MediaStore ACTION IMAGE CAPTURE startActivityForResult takePictureIntent 1
  • 在调试模式下,哪些代码更改会自动反映在 Eclipse 中?

    我使用 eclipse 用于编写 调试 作为 IDE 在调试模式下 当我进行一些更改 例如初始化局部变量 时 它们会自动反映 但其他更改例如更改静态变量的值 有时我会收到一条消息 说我需要重新启动虚拟机 有时则不需要 现在的问题是哪些类型的
  • Spring Data JPA 和 Exists 查询

    我正在使用 Spring Data JPA 使用 Hibernate 作为我的 JPA 提供程序 并想要定义一个exists附加 HQL 查询的方法 public interface MyEntityRepository extends C
  • PostgreSQL 使用 JPA 和 Hibernate 抛出“列的类型为 jsonb,但表达式的类型为 bytea”

    这是我的实体类 映射到表中postgres 9 4 我正在尝试将元数据存储为jsonb在数据库中输入 Entity Table name room categories TypeDef name jsonb typeClass JsonBi
  • 如何在 SpringDoc OpenAPI 3 中引用文件?

    我有 Spring Boot 项目 我想在其中记录我的 API 这里是正在处理的 Web 服务的示例 ApiResponses value ApiResponse responseCode 200 content Content media

随机推荐