简体   繁体   English

域类中的值占位符

[英]value placeholder in Domain classes

I have a maven project in Eclipse called TdkUtils, with this pom.xml: This is a utils project. 我在Eclipse中有一个名为TdkUtils的maven项目,带有以下pom.xml:这是一个utils项目。 So I want to create a jar, put it in the repository and use it in another projects. 因此,我想创建一个jar,将其放入存储库中,并在其他项目中使用它。

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 我也尝试将值放入文件application.properties ,结果相同

I also have in the configuration file the path to the domain classes 我在配置文件中也有域类的路径

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

尝试在Configuration类上添加ComponentScan(“ package PathOfYourDomainClassGoesHere”)批注

@COnfiguration,@ComponentScan(basePackage={""}),@PropertySource("classpath:*.properties) @配置,@ ComponentScan(basePackage = { “”}),@ PropertySource(“类路径:*特性)

The above 3 annotations are necessary to use to obtain the required result. 要获得所需的结果,必须使用以上3个注释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM