有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (1) 个答案

  1. # 1 楼答案

    除了Nawnit Sen的评论之外

    至于我,我把它放在了本地磁盘文件系统中

    我还授予tomcat用户该文件夹的所有权限

    root-context.xml文件中,我为这两种情况注册了两个属性文件(我在Windows上开发,在Linux上部署)。只能注册一个属性文件

    <context:property-placeholder location="file:/path/to/application.properties" order="1" ignore-resource-not-found="true" ignore-unresolvable="true" />
    <context:property-placeholder location="file:C:/path/to/application.properties" order="2" ignore-resource-not-found="true" ignore-unresolvable="true" />
    

    现在在你的课堂上,你可以得到这样的属性

    import org.springframework.beans.factory.annotation.Value;
    
    @Value("${someProperty}")  
    private String yourProperty;