POM示例

最后更新:2024-09-09 05:30:01 | 状态:未完成
如果需要私服参考这里>maven私服

通常情况下每个公司会有自己的*-starter或*-dependency来统一管理maven依赖版本号

示例代码中pom按如下格式定义:

anyline-simple-dependency中主要配置了一些基础依赖如log/io/lang/spring以及maven私服地址(注意其中的repository.id要与本地maven/conf/setting.conf中的servers.server.id对应)

anyline-simple-dependency-web继承自anyline-simple-dependency并添加了web环境的依赖。

anyline-simple-startanyline-simple-dependency基础上定义了当前项目中需要的一些基础依赖

anyline-simple-start-mysql继承自anyline-simple-start并添加了mysql的依赖。

anyline-simple-start-mvc-mysql继承anyline-simple-start并添加了mysql与springmvc的依赖。

接下来所有需要myql和mvc环境的项目都继承自anyline-simple-start-mvc-mysql

如果不想搞那多花里胡哨的,忽略上面的,直接把以下POM复制到项目中

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <!--这里的parent 实际项目中一般要换成继承自己公司的start或parent -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.3</version>
        <relativePath></relativePath>
    </parent>

    <artifactId>anyline-simple-alpha-clear</artifactId>
    <description>
        这是一个独立的项目,spring-boot环境,与其他模块没有任何关系,直接运行
        现有项目基础上要集成anyline可以参考这里
        项目中主要用到Anyline(可以继承AnylineController或者在需要的位置注入)
        主要配置了maven仓库以及mvc环境和jdbc环境
        其他的一些依赖一般用现有项目的就可以
    </description>

    <dependencyManagement>
    <dependencies>
        <!--
            这里主要定义了一些版本号
            实现项目中也是换成各自公司自己的
        -->
        <dependency>
            <groupId>org.anyline</groupId>
            <artifactId>anyline-dependency</artifactId>
            <version>8.7.2-SNAPSHOT</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
    </dependencyManagement>
    <dependencies>
        <!--  mvc环境 -->
        <dependency>
            <groupId>org.anyline</groupId>
            <artifactId>anyline-mvc</artifactId>
        </dependency>

        <!-- mysql环境 -->
        <dependency>
            <groupId>org.anyline</groupId>
            <artifactId>anyline-data-jdbc-mysql</artifactId>
        </dependency>

        <!--  mysql驱动 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <!--一些公用依赖 一般也是继承自公司自己的parent-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
        </dependency>


        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.7</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-access</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>


首页 最近更新 搜索 提交 回复