Skip to content

Conversation

@alitr86-hue
Copy link

Summary

Added a new REST endpoint /api/version that returns the current application version defined in pom.xml.

Implementation Details

  • Created a new class VersionController in org.springframework.samples.petclinic.system.
  • Added the app.version property to application.properties.
  • Updated pom.xml to enable Maven resource filtering.

Verification

  • The project builds successfully with mvn clean package.
  • Running http://localhost:8080/api/version returns:
    {
    "version": "4.0.0-SNAPSHOT"
    }

@snicoll
Copy link
Member

snicoll commented Nov 12, 2025

Thanks for the PR. What's the reason for exposing the version?

public class VersionController {

@Value("${app.version:unknown}")
private String version ="unknown";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private String version ="unknown";
private String version = "unknown";

public class VersionController {

@Value("${app.version:unknown}")
private String version ="unknown";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's default here, you have default on annotation level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants