pom.xml常用模版

父項(xiàng)目pom.xml模版

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>sunyu.parent</groupId>
    <artifactId>sunyu-parent</artifactId>
    <version>1.0-SNAPSHOT</version>

    <packaging>pom</packaging>

    <name>sunyu-parent</name>
    <url>http://maven.apache.org</url>

    <!-- maven倉(cāng)庫(kù) -->
    <!--<repositories>
        <repository>
            <id>nutz</id>
            <url>https://jfrog.nutz.cn/artifactory/jcenter</url>
        </repository>
        <repository>
            <id>nutz-snapshots</id>
            <url>https://jfrog.nutz.cn/artifactory/snapshots</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
        <repository>
            <id>github-releases</id>
            <url>http://oss.sonatype.org/content/repositories/github-releases/</url>
        </repository>
        <repository>
            <id>clojars.org</id>
            <url>http://clojars.org/repo</url>
        </repository>
    </repositories>-->

    <!-- 分發(fā)至遠(yuǎn)程倉(cāng)庫(kù) -->
    <!--
    <distributionManagement>
        <snapshotRepository>
            <id>Snapshots</id>
            <name>Internal Snapshots</name>
            <url>http://121.40.56.224:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
        <repository>
            <id>yibank</id>
            <name>yibank repository</name>
            <url>http://121.40.56.224:8081/nexus/content/repositories/yibank/</url>
        </repository>
    </distributionManagement>
    -->

    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <!-- 父項(xiàng)目這里應(yīng)該是使用dependencyManagement的。
    但是為了開發(fā)調(diào)試方便,方便排查包依賴錯(cuò)誤,先使用 dependencies方式,
    等后期jar包依賴穩(wěn)定后再更改為dependencyManagement -->
    <!-- <dependencyManagement></dependencyManagement> -->
    <dependencies>

        <!-- 解決Missing artifact問(wèn)題,也可以解決maven jetty插件運(yùn)行錯(cuò)誤等問(wèn)題,還可以解決一些莫名其妙的問(wèn)題 -->
        <dependency>
            <groupId>jdk.tools</groupId>
            <artifactId>jdk.tools</artifactId>
            <version>1.8</version>
            <scope>system</scope>
            <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
        </dependency>

        <!-- web項(xiàng)目依賴,主要是解決項(xiàng)目中使用了request和response、session等原生對(duì)象找不到類的問(wèn)題 -->
        <!--<dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>-->
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- spring mvc -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.3.5.RELEASE</version>
        </dependency>
        <!-- spring jdbc -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>4.3.5.RELEASE</version>
        </dependency>
        <!-- spring context -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>4.3.5.RELEASE</version>
        </dependency>
        <!-- spring jms -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
            <version>4.3.5.RELEASE</version>
        </dependency>
        <!-- spring test -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>4.3.5.RELEASE</version>
        </dependency>
        <!-- spring aop需要的jar -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.8.10</version>
        </dependency>

        <!-- log4j2日志依賴 -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.22</version>
        </dependency>
        <!-- log4j2 -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.7</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.7</version>
        </dependency>
        <!-- 用于slf4j與log4j2橋接 -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>2.7</version>
        </dependency>
        <!-- commons-logging與log4j2橋接 -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-jcl</artifactId>
            <version>2.7</version>
        </dependency>
        <!-- web工程需要的log4j2 -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-web</artifactId>
            <version>2.7</version>
        </dependency>
        <!-- 這個(gè)包為了兼容以前項(xiàng)目的日志 -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-1.2-api</artifactId>
            <version>2.7</version>
        </dependency>

        <!-- junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <!-- junit assertThat的時(shí)候使用的包 -->
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>

        <!-- jackson springmvc的@ResponseBody使用的依賴包 json/xml轉(zhuǎn)換工具類 -->
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
            <version>2.8.5</version>
        </dependency>

        <!-- nutz -->
        <dependency>
            <groupId>org.nutz</groupId>
            <artifactId>nutz</artifactId>
            <version>1.r.59</version>
        </dependency>

        <!-- jFinal -->
        <dependency>
            <groupId>com.jfinal</groupId>
            <artifactId>jfinal</artifactId>
            <version>2.2</version>
        </dependency>

        <!-- fst序列化工具 -->
        <dependency>
            <groupId>de.ruedigermoeller</groupId>
            <artifactId>fst</artifactId>
            <version>2.48</version>
        </dependency>

        <!-- jodd工具 -->
        <dependency>
            <groupId>org.jodd</groupId>
            <artifactId>jodd-core</artifactId>
            <version>3.8.0</version>
        </dependency>

        <!-- commons工具類 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.5</version>
        </dependency>

        <!-- 編碼解碼工具類 -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.10</version>
        </dependency>

        <!-- 阿里巴巴數(shù)據(jù)源 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.27</version>
        </dependency>

        <!-- mysql驅(qū)動(dòng)類 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <!-- 坑人的6版本,需要mysql必須是新版才行 -->
            <!-- <version>6.0.5</version> -->
            <version>5.1.40</version>
        </dependency>

        <!-- mongo驅(qū)動(dòng) -->
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongodb-driver</artifactId>
            <version>3.4.1</version>
        </dependency>

        <!-- redis客戶端 -->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.9.0</version>
        </dependency>

        <!-- beetl模版 -->
        <dependency>
            <groupId>com.ibeetl</groupId>
            <artifactId>beetl</artifactId>
            <version>2.7.5</version>
        </dependency>

        <!-- javamelody監(jiān)控 -->
        <dependency>
            <groupId>net.bull.javamelody</groupId>
            <artifactId>javamelody-core</artifactId>
            <version>1.62.0</version>
        </dependency>

        <!-- activeMq -->
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-pool</artifactId>
            <version>5.14.3</version>
        </dependency>

        <!-- solrj -->
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-solrj</artifactId>
            <version>6.3.0</version>
        </dependency>

        <!-- quartz -->
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
            <version>2.2.3</version>
        </dependency>

        <!-- mina -->
        <dependency>
            <groupId>org.apache.mina</groupId>
            <artifactId>mina-core</artifactId>
            <version>2.0.16</version>
        </dependency>

        <!-- hbase -->
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-server</artifactId>
            <version>1.2.4</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- kafka -->
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_2.12</artifactId>
            <version>0.10.1.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- kafka client -->
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <!-- kafka客戶端與服務(wù)器端版本要對(duì)應(yīng),否則會(huì)出現(xiàn)下面錯(cuò)誤 -->
            <!-- org.apache.kafka.common.protocol.types.SchemaException: Error reading field 'brokers': Error reading field 'host': Error reading string of length 25444, only 88 bytes available -->
            <!-- 這個(gè)版本號(hào)對(duì)應(yīng)kafka版本號(hào),例如(kafka_2.11-0.10.1.1),據(jù)我多年臨床經(jīng)驗(yàn),這個(gè)0.10.1.1應(yīng)該對(duì)應(yīng)才行 -->
            <version>0.10.1.1</version>
            <!--<version>0.9.0.1</version>-->
        </dependency>

        <!-- storm -->
        <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-core</artifactId>
            <version>1.0.2</version>
        </dependency>
        <!-- storm整合kafka -->
        <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-kafka</artifactId>
            <version>1.0.2</version>
        </dependency>

        <!-- mybatis -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.4.1</version>
        </dependency>
        <!-- spring整合mybatis -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>1.3.0</version>
        </dependency>
        <!-- mybatis分頁(yè)插件 -->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
            <version>4.2.1</version>
        </dependency>

        <!-- spring整合shiro -->
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-spring</artifactId>
            <version>1.3.2</version>
        </dependency>
        <!-- shiro整合ehcache -->
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-ehcache</artifactId>
            <version>1.3.2</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerVersion>1.8</compilerVersion>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!-- 跳過(guò)單元測(cè)試 -->
                    <skip>true</skip>
                    <forkMode>once</forkMode>
                    <argLine>-Dfile.encoding=UTF-8</argLine>
                </configuration>
            </plugin>

            <!-- 編譯時(shí)更改配置文件插件 -->
            <plugin>
                <groupId>com.juvenxu.portable-config-maven-plugin</groupId>
                <artifactId>portable-config-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>replace-package</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration/>
            </plugin>
        </plugins>
    </build>

    <modules>
        <module>sunyu-config</module>
        <module>sunyu-mapper</module>
        <module>sunyu-kit</module>
        <module>sunyu-service</module>
        <module>sunyu-storm</module>
        <module>sunyu-controller</module>
        <module>sunyu-quartz</module>
        <module>sunyu-web</module>
    </modules>

</project>

WEB項(xiàng)目常用pom.xml模版

<?xml version="1.0"?>
<project 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"
         xmlns="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>sunyu.web</groupId>
        <artifactId>sunyu-web</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>sunyu.web.shiro</groupId>
    <artifactId>sunyu-web-shiro</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>sunyu-web-shiro Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <dependencies>
        <dependency>
            <groupId>sunyu.controller.shiro</groupId>
            <artifactId>sunyu-controller-shiro</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>sunyu-web-shiro</finalName>

        <plugins>
            <!-- 配置Maven插件(mvn jetty:run-exploded可以運(yùn)行項(xiàng)目,也可以mvn -Djetty.port=8080 jetty:run-exploded) -->
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <configuration>
                    <!-- 指定訪問(wèn)端口,最好是使用-Djetty.port=8080參數(shù)指定 -->
                    <!--<httpConnector>
                        <port>8080</port>
                    </httpConnector>-->
                    <!-- 間隔x秒掃描一次,實(shí)現(xiàn)熱部署 -->
                    <scanIntervalSeconds>1</scanIntervalSeconds>
                    <!-- 編寫類文件之后,是否自動(dòng)重啟jetty;可選后面兩個(gè)值[manual|automatic] -->
                    <reload>automatic</reload>
                    <!-- 指定關(guān)閉端口 -->
                    <!--<stopPort>65535</stopPort>-->
                    <!--<stopKey>stop-jetty-for-it</stopKey>-->
                    <webApp>
                        <contextPath>/</contextPath>
                        <!-- 更改jetty默認(rèn)webdefault.xml文件,主要修改了useFileMappedBuffer屬性為false,使其不鎖定靜態(tài)文件 -->
                        <!-- 此文件在C盤\用戶目錄\.m2\repository\org\eclipse\jetty\jetty-webapp\xxxVersion\找到j(luò)ar包,打開jar包目錄org\eclipse\jetty\webapp\目錄中 -->
                        <!--<defaultsDescriptor>webdefault.xml</defaultsDescriptor>-->
                    </webApp>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

WEB項(xiàng)目web.xml常用模版

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                             http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">

    <display-name>Shiro Web Application</display-name>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:spring-*.xml</param-value>
    </context-param>
    <listener>
        <description>spring監(jiān)聽器</description>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <description>防止spring內(nèi)存溢出監(jiān)聽器</description>
        <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
    </listener>

    <filter>
        <description>字符集過(guò)濾器</description>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <description>字符集編碼</description>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- 開啟shiro功能時(shí)才需要這個(gè)filter配置 -->
    <filter>
        <filter-name>shiroFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        <init-param>
            <!-- 該值缺省為false,表示生命周期由SpringApplicationContext管理,設(shè)置為true則表示由ServletContainer管理 -->
            <param-name>targetFilterLifecycle</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>shiroFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
        <description>spring mvc servlet</description>
        <servlet-name>springMvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <description>spring mvc 配置文件</description>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:springMvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>springMvc</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!-- 添加javamelody監(jiān)控,訪問(wèn)方式:http://host:port/WebAppName/monitoring -->
    <filter>
        <filter-name>monitoring</filter-name>
        <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
        <init-param>
            <param-name>monitoring-path</param-name>
            <!-- 配置javamelody訪問(wèn)地址 -->
            <param-value>/monitoring</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>monitoring</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!-- javamelody監(jiān)聽器 -->
    <listener>
        <listener-class>net.bull.javamelody.SessionListener</listener-class>
    </listener>

    <!-- druid數(shù)據(jù)源Web監(jiān)控配置 -->
    <filter>
        <filter-name>druidWebStat</filter-name>
        <filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>druidWebStat</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!-- druid監(jiān)控頁(yè)面,使用http://host:port/WebAppName/druid訪問(wèn) -->
    <servlet>
        <servlet-name>druidStatView</servlet-name>
        <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>druidStatView</servlet-name>
        <url-pattern>/druid/*</url-pattern>
    </servlet-mapping>

</web-app>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容