Banner
patorjk - Text to ASCII Art Generator
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
</parent>
spring-boot-starter-parent。 為了防止 Maven 的變數佔位符 ${} 與 Spring 自己的屬性佔位符(例如 @Value("${...}"))搞混,Spring Boot 在父 POM 中將 Maven 資源過濾的預設符號從 ${} 改成了 @。
resources/banner.txt
your banner art...
:: Project : @project.name@
:: Version : @project.version@
:: Profile : ${spring.profiles.active:default}
:: Java : ${java.version}
:: Documentation: http://localhost:${server.port}/swagger-ui/index.html
pom.xml
在你的 pom.xml 中,<groupId> 下方補上 <name>。雖然 artifactId 是標識符,但 @project.name@ 優先抓取的是 <name>:
<groupId>com.example</groupId>
<artifactId>order-service</artifactId>
<name>Order Service</name>
<version>1.0.0</version>
修正 Resources 配置 (明確包含檔案)
有時候 Maven 會因為預設路徑問題跳過過濾。建議將 build 區塊改得更精確一點:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/banner.txt</include>
<include>**/application*.yml</include>
<include>**/application*.properties</include>
</includes>
</resource>
</resources>
</build>
在 IDE 中執行 mvn clean compile
result:
Connected to the target VM, address: '127.0.0.1:56641', transport: 'socket'
__ _
___ _______/ /__ _______ ___ _____ __(_)______
/ _ \/ __/ _ / -_) __(_-</ -_) __/ |/ / / __/ -_)
\___/_/ \_,_/\__/_/ /___/\__/_/ |___/_/\__/\__/
:: Project : order-service
:: Version : 1.0.0
:: Profile : default
:: Java : 21
:: Documentation: http://localhost:8082/swagger-ui/index.html
2026-02-01T18:24:07.307+08:00 INFO 20632 --- [order-service] [ main] c.e.o.OrderServiceApplication : Starting OrderServiceApplication using Java 21 with PID 20632 (E:\demo\orderse