• Maven 的其它插件


    Maven 的其它插件

    dockerfile 插件

    dockerfile-maven-plugin 是 spotify 公司新提供的、用以替代 docker-maven-plugin 的插件,它同样是用于在 maven 中将当前项目打成一个 docker image 。 相较于 docker-maven-plugin 而言,dockerfile-maven-plugin 更简洁、方便。

    <plugin>
        <groupId>com.spotifygroupId>
        <artifactId>dockerfile-maven-pluginartifactId>
        <version>1.4.13version>
        <configuration>
            <repository>${project.artifactId}repository>
            <tag>${project.version}tag>
            <buildArgs>
                <JAR_FILE>${project.build.finalName}.jarJAR_FILE>
            buildArgs>
        configuration>
    plugin>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    dockerfile-maven-plugin 插件会要求在项目的根目录下(也就是 pom.xml 文件的平级目录下)存在一个 Dockerfile 文件,它会去用这个 Dockerfile 文件生成 docker image 。

    FROM openjdk:8-jre-slim-bullseye
    ARG JAR_FILE
    ADD target/${JAR_FILE} app.jar
    
    EXPOSE 8080
    ENTRYPOINT exec java -jar /app.jar
    ## ENTRYPOINT ["java", "-jar", "/app.jar"]
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    Apache Maven Checkstyle Plugin

    Apache 基金会的 maven checkstyle 插件能帮程序员检测代码中不符合规范的地方,大大方便程序开发。

    checkstyle 默认使用 sun 公司的编程规范来检查代码规范。如果你像自定义校验规则,你需要提供一个 checkstyle.xml 配置文件,在配置文件中按 checkstyle 的规则启用或关闭某个规则。

    不过随着《阿里巴巴 Java 开发手册》的流行,阿里巴巴推出了类似的 maven 插件 p3c-pmd,因此,checkstyle 慢慢被 p3c-pmd 取代了。

    p3c-pmd

    P3C-PMD 插件基于 PMD 实现了《阿里巴巴 Java 开发手册》中涉及的 48 条规则。

    
    <plugin>
        <groupId>org.apache.maven.pluginsgroupId>
        <artifactId>maven-pmd-pluginartifactId>
        <version>3.13.0version>
        <configuration>
            <rulesets>
                <ruleset>rulesets/java/ali-naming.xmlruleset>
                
            rulesets>
            <printFailingErrors>trueprintFailingErrors>
        configuration>
        <executions>
            <execution>
                <id>validateid>
                <phase>validatephase>
                <goals>
                    <goal>checkgoal>
                goals>
            execution>
        executions>
        <dependencies>
            
            <dependency>
                <groupId>com.alibaba.p3cgroupId>
                <artifactId>p3c-pmdartifactId>
                <version>2.1.0version>
            dependency>
        dependencies>
    plugin>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
  • 相关阅读:
    CRM系统中的销售漏斗有什么作用?
    在 Web 项目中应用 Apache Shiro
    Java_线程的概念和线程的创建的方法
    两个有序链表序列的交集
    CVE-2022-40871 Dolibarr任意添加管理员与RCE漏洞分析
    Go语言excelize包-02-工作表操作
    【23种设计模式】抽象工厂模式(三)
    初入编程之门的个人建议1.0
    “WeekendMeaningfulThings“ app Tech Support(URL)
    是时候掌握SpringMVC源码了-初探篇
  • 原文地址:https://blog.csdn.net/m0_73393501/article/details/132684191