多模块Spring Boot应用程序:如何将时间戳添加到每个模块中的JAR文件中,输出“ JAR”
我有来自父母和其他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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论