我有一个Spring Boot 2.1.0.RELEASE项目。如何查看其使用的百里香叶版本?
答案 0 :(得分:0)
根据Spring Docs,您可以使用应用程序属性文件轻松地做到这一点。
您可以使用以下命令自动扩展Maven项目中的属性 资源过滤。如果您使用spring-boot-starter-parent,则可以 然后通过@ .. @占位符引用您的Maven“项目属性”
Maven pom.xml:
TO
Spring application.properties:
<groupId>com.poo</groupId>
<artifactId>gar</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Poo</name>
<description>Gar</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
然后可以使用带有@ControllerAdvice注释的类将版本作为模型属性注入。
poo.app.version=@project.version@
最后,Thymeleaf可以像其他任何属性一样访问此模型属性。使用th:text标签,尝试访问下面的model属性,以便您可以显示您的应用使用的Thymeleaf版本:
@ControllerAdvice
public class ControllerAdvice {
@Value("${poo.app.version}")
private String applicationVersion;
@ModelAttribute("applicationVersion")
public String getApplicationVersion() {
return applicationVersion;
}}
答案 1 :(得分:0)
答案 2 :(得分:0)
如果您使用的是Maven,则可以使用list
的maven dependecy plugin目标:
$ mvn dependency:list -DincludeArtifactIds=thymeleaf
或使用Maven包装器:
$ ./mvnw dependency:list -DincludeArtifactIds=thymeleaf
maven的示例输出:
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ site ---
[INFO]
[INFO] The following files have been resolved:
[INFO] org.thymeleaf:thymeleaf:jar:3.0.9.RELEASE:compile
对于成绩:
$ gradle dependencyInsight --dependency org.thymeleaf:thymeleaf
使用包装器
$ ./gradlew dependencyInsight --dependency org.thymeleaf:thymeleaf
Gradle的示例输出:
org.thymeleaf:thymeleaf:2.1.6.RELEASE (selected by rule)
\--- org.thymeleaf:thymeleaf-spring4:2.1.6.RELEASE
\--- org.springframework.boot:spring-boot-starter-thymeleaf:1.5.9.RELEASE
\--- compile
org.thymeleaf:thymeleaf:2.1.4.RELEASE -> 2.1.6.RELEASE
\--- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:1.4.0
\--- org.springframework.boot:spring-boot-starter-thymeleaf:1.5.9.RELEASE
\--- compile
org.thymeleaf:thymeleaf-spring4:2.1.6.RELEASE (selected by rule)
\--- org.springframework.boot:spring-boot-starter-thymeleaf:1.5.9.RELEASE
\--- compile