多模块Spring Boot应用程序:如何将时间戳添加到每个模块中的JAR文件中,输出“ JAR”

发布于 2025-02-08 07:29:55 字数 6985 浏览 1 评论 0原文

我有来自父母和其他2个模块的pom.xml。我正在尝试添加一个时间戳,例如e-version-1.0.001-06-15-2022-09-32.jar,

我所有的模块都应输出时间戳记。我很难。

尝试的解决方案:

在构建标签中添加的属性和最终名称,这是构建1个模块,但其余模块失败了? '''

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.build.timestamp.format>yyyy-MM-dd'T'HH-mm-ss'Z'</maven.build.timestamp.format>
    <timestamp>${maven.build.timestamp}</timestamp>
    <outputFolder>C:/AutomationTestReports/${project.name}/Execution_(${timestamp})</outputFolder>
</properties>
<build>
<finalName>${project.artifactId}-${maven.build.timestamp}</finalName>
</build>

''' parent pom.xml

'''''

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
    <!-- Spring IO Platform is the parent of the generated application to
    be able to use Spring Boot and all its default configuration -->
    <parent>
        <groupId>io.spring.platform</groupId>
        <artifactId>platform-bom</artifactId>
        <version>2.0.1.RELEASE</version>
    </parent>
    <groupId>sample.multimodule</groupId>
    <artifactId>sample.multimodule</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>Parent - Pom Aggregator</name>
    <description>This pom is a maven aggregator that contains all application modules. Also, include all
    common dependencies needed by more than one module. Dependencies are defined without version because
    this project has defined Spring IO Platform as parent.</description>

    <properties>
      <java.version>1.8</java.version>
        <maven.build.timestamp.format>yyyy-MM-dd-HH-mm</maven.build.timestamp.format>
    </properties>

    <modules>
      <module>model</module>
      <module>repository</module>
      <module>service-api</module>
      <module>service-impl</module>
      <module>application</module>
    </modules>

    <dependencies>

      <!-- Spring Boot dependencies -->
      <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter</artifactId>
          </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
      </dependency>
          <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-test</artifactId>
              <scope>test</scope>
          </dependency>
    </dependencies>

</project>

'''''''''''

''''''''''''

'

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
        <groupId>sample.multimodule</groupId>
        <artifactId>sample.multimodule</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>sample.multimodule.application</artifactId>
    <packaging>jar</packaging>
    <name>Project Module - Application</name>
   
    <dependencies>

      <!-- Project modules -->
      <dependency>
        <groupId>sample.multimodule</groupId>
        <artifactId>sample.multimodule.service.impl</artifactId>
        <version>${project.version}</version>
      </dependency>

      <!-- Spring Boot dependencies -->
          <dependency>
              <groupId>org.apache.tomcat.embed</groupId>
              <artifactId>tomcat-embed-jasper</artifactId>
              <scope>provided</scope>
          </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
      </dependency>
    
    </dependencies>
    
    <build>
        <plugins>
            <!-- Spring Boot plugins -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

'''''''

'

'

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
        <groupId>sample.multimodule</groupId>
        <artifactId>sample.multimodule</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>sample.multimodule.service.impl</artifactId>
    <packaging>jar</packaging>
    <name>Project Module - Service Implementation</name>
    <description>Module that contains services implementation defined on Service API module. Depends of Repository Module and 
    Service API Module.</description>    

    <dependencies>

      <!-- Project Modules -->
      <dependency>
        <groupId>sample.multimodule</groupId>
        <artifactId>sample.multimodule.repository</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>sample.multimodule</groupId>
        <artifactId>sample.multimodule.service.api</artifactId>
        <version>${project.version}</version>
      </dependency>

    </dependencies>

    
</project>

'''

I have pom.xml from the parent and the other 2 modules. I am trying to add a timestamp like E-Version-1.0.001-06-15-2022-09-32.jar

All my modules should output files with time stamps. I have a hard time.

Tried possible solutions:

Added properties and final name in build tag, This builds 1 module but the remaining module fails?
'''

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.build.timestamp.format>yyyy-MM-dd'T'HH-mm-ss'Z'</maven.build.timestamp.format>
    <timestamp>${maven.build.timestamp}</timestamp>
    <outputFolder>C:/AutomationTestReports/${project.name}/Execution_(${timestamp})</outputFolder>
</properties>
<build>
<finalName>${project.artifactId}-${maven.build.timestamp}</finalName>
</build>

'''
Parent pom.xml

'''

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
    <!-- Spring IO Platform is the parent of the generated application to
    be able to use Spring Boot and all its default configuration -->
    <parent>
        <groupId>io.spring.platform</groupId>
        <artifactId>platform-bom</artifactId>
        <version>2.0.1.RELEASE</version>
    </parent>
    <groupId>sample.multimodule</groupId>
    <artifactId>sample.multimodule</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>Parent - Pom Aggregator</name>
    <description>This pom is a maven aggregator that contains all application modules. Also, include all
    common dependencies needed by more than one module. Dependencies are defined without version because
    this project has defined Spring IO Platform as parent.</description>

    <properties>
      <java.version>1.8</java.version>
        <maven.build.timestamp.format>yyyy-MM-dd-HH-mm</maven.build.timestamp.format>
    </properties>

    <modules>
      <module>model</module>
      <module>repository</module>
      <module>service-api</module>
      <module>service-impl</module>
      <module>application</module>
    </modules>

    <dependencies>

      <!-- Spring Boot dependencies -->
      <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter</artifactId>
          </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
      </dependency>
          <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-test</artifactId>
              <scope>test</scope>
          </dependency>
    </dependencies>

</project>

'''

Application Module Pom.xml

'''

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
        <groupId>sample.multimodule</groupId>
        <artifactId>sample.multimodule</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>sample.multimodule.application</artifactId>
    <packaging>jar</packaging>
    <name>Project Module - Application</name>
   
    <dependencies>

      <!-- Project modules -->
      <dependency>
        <groupId>sample.multimodule</groupId>
        <artifactId>sample.multimodule.service.impl</artifactId>
        <version>${project.version}</version>
      </dependency>

      <!-- Spring Boot dependencies -->
          <dependency>
              <groupId>org.apache.tomcat.embed</groupId>
              <artifactId>tomcat-embed-jasper</artifactId>
              <scope>provided</scope>
          </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
      </dependency>
    
    </dependencies>
    
    <build>
        <plugins>
            <!-- Spring Boot plugins -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

'''

Sevice Module pom.xml

'''

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
        <groupId>sample.multimodule</groupId>
        <artifactId>sample.multimodule</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>sample.multimodule.service.impl</artifactId>
    <packaging>jar</packaging>
    <name>Project Module - Service Implementation</name>
    <description>Module that contains services implementation defined on Service API module. Depends of Repository Module and 
    Service API Module.</description>    

    <dependencies>

      <!-- Project Modules -->
      <dependency>
        <groupId>sample.multimodule</groupId>
        <artifactId>sample.multimodule.repository</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>sample.multimodule</groupId>
        <artifactId>sample.multimodule.service.api</artifactId>
        <version>${project.version}</version>
      </dependency>

    </dependencies>

    
</project>

'''

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文