I have class that one of it's parameters i want to set from properties file:
import org.springframework.beans.factory.annotation.Value; (..) @Getter @Setter @NoArgsConstructor public class ConvertNonStandardOfferRequestDtoWrapper { private ConvertNonStandardOfferRequestDto convertNonStandardOfferRequestDto; @Value("true") private boolean documentPrintoutsRequired; public ConvertNonStandardOfferRequestDtoWrapper(ConvertNonStandardOfferRequestDto convertNonStandardOfferRequestDto) { this.convertNonStandardOfferRequestDto = convertNonStandardOfferRequestDto; } } What i see inside constructor is that documentPrintoutsRequired is false instead of true. I see that when debuging and setting breakpoint inside constructor. And i have a pom file for this module:
<modelVersion>4.0.0</modelVersion> <parent> <groupId>x</groupId> <artifactId>policy</artifactId> <version>4.0-SNAPSHOT</version> </parent> <artifactId>policy-api</artifactId> <dependencies> <dependency> <groupId>x</groupId> <artifactId>common-api</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>${guava.version}</version> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> </dependencies> <build> (...) </build> </project> I am wonderning why @value does not work correctly ?
falsein the constructor. The@Valuewill be resolved after the object has been constructed, hence after the constructor.false@Valuewill only work for Spring managed beans.newkeyword.