value placeholder in Domain classes

368 views Asked by At

I have a maven project in Eclipse called TdkUtils, with this pom.xml: This is a utils project. So I want to create a jar, put it in the repository and use it in another projects.

I have this domain class:

@PropertySource("recommended-mobile.properties")
public class RemoteUnit implements Serializable {

    private static final long serialVersionUID = 1L;

    private RemoteUnitType remoteUnitType;

    private long remoteUnitId;

    private String serialNumber;

    private String imei;

    private String softwareVersion;

    private String msisdn;

    @Value("${AX1}")
    private String firmwareAX1;

    @Value("${AX1Pro}")
    private String firmwareAX1Pro;

    @Value("${AX5}")
    private String firmwareAX5;

 ...
}

But it's not replacing the values at all. Maybe its only possible in the config files ?

I also tries to put the values in the file application.properties with the same result

I also have in the configuration file the path to the domain classes

@ComponentScan(value="com.tdk.domain")
2

There are 2 answers

0
Sunil Singhal On BEST ANSWER

Try adding the ComponentScan("package PathOfYourDomainClassGoesHere") annotation on your Configuration class

0
Arpit Agrawal On

@COnfiguration,@ComponentScan(basePackage={""}),@PropertySource("classpath:*.properties)

The above 3 annotations are necessary to use to obtain the required result.