Given an env var starting with #, when declared using @Value or @ConfigurationProperties, it isn't loaded.

Code:

@Value("${my.variable}")
String variable;

or

@Component
@ConfigurationProperties(prefix = "my")
public class ServiceNowProperties {
    private String variable;
    ....
}

ENV VAR:

MY_VARIABLE=#my_value

Expected result (and result in 3.4.5):

variable contains the string "#my_value"

Current result (3.5.0):

no value is present in the variable.

Comment From: wilkinsona

Thanks for the report but I cannot reproduce the behavior that you have described. Here's my sample application:

package com.example.gh_45886;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

import com.example.gh_45886.Gh45886Application.MyProperties;

@SpringBootApplication
@EnableConfigurationProperties(MyProperties.class)
public class Gh45886Application {

    Gh45886Application(@Value("${my.variable}") String valueVariable, MyProperties myProperties) {
        System.out.println("@ConfigurationProperties my.variable = " + myProperties.getVariable());
        System.out.println("@Value my.variable = " + valueVariable);
    }

    public static void main(String[] args) {
        SpringApplication.run(Gh45886Application.class, args);
    }

    @ConfigurationProperties(prefix = "my")
    static class MyProperties {

        private String variable;

        public String getVariable() {
            return variable;
        }

        public void setVariable(String variable) {
            this.variable = variable;
        }

    }

}

And here's the output when it's run:

MY_VARIABLE=#test java -jar target/gh-45886-0.0.1-SNAPSHOT.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.5.0)

2025-06-11T16:27:43.653+01:00  INFO 57794 --- [gh-45886] [           main] c.example.gh_45886.Gh45886Application    : Starting Gh45886Application v0.0.1-SNAPSHOT using Java 21.0.5 with PID 57794 (/Users/aw036093/dev/temp/spring-projects/spring-boot/gh-45886/target/gh-45886-0.0.1-SNAPSHOT.jar started by aw036093 in /Users/aw036093/dev/temp/spring-projects/spring-boot/gh-45886)
2025-06-11T16:27:43.655+01:00  INFO 57794 --- [gh-45886] [           main] c.example.gh_45886.Gh45886Application    : No active profile set, falling back to 1 default profile: "default"
@ConfigurationProperties my.variable = #test
@Value my.variable = #test
2025-06-11T16:27:43.860+01:00  INFO 57794 --- [gh-45886] [           main] c.example.gh_45886.Gh45886Application    : Started Gh45886Application in 0.384 seconds (process running for 0.588)

As you can see, the #test value is successfully consumed using both @ConfigurationProperties and @Value.

If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: devdevx

Thanks for the response. After further investigation, I’ve realized that the true issue was not related to the env var interpretation. Closing this issue as it's not relevant here.

Thanks!