在Java Spring项目中定义属性引用的可能位置在哪里

时间:2015-09-07 12:49:19

标签: java spring spring-mvc

我目前正在尝试了解一些遗留的Java Spring MVC代码,并且很难找到代码中属性引用的位置。我遇到了两种类型的引用注释:

${aaa.bbb.ccc}

现在我的问题是两种引用属性的方法之间的区别是什么?我在哪里可以找到适当的来源?

更新: 所以@PORT@是如何根据answeres指定Spring中的属性。现在问题的第一部分是*.properties来自哪里。此引用可以在/var/www文件

中找到

2 个答案:

答案 0 :(得分:0)

搜索以* .properties结尾的文件!

如果你有上下文的话,那就是:

<bean id="myProperties"
      class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="myProperties">
    <list>
      <value>classpath:file.properties</value>
    </list>
  </property>
</bean>

你可以拥有一个属性为

的spring bean
    .root{
    -fx-font-family: "Courier New";
}

同时检查此link http://www.baeldung.com/2012/02/06/properties-with-spring/

答案 1 :(得分:0)

我认为@...@是maven过滤,因为spring属性和maven的默认分隔符与${...}相同,@...@使用<replace file="configure.sh" value="defaultvalue" propertyFile="src/name.properties"> <replacefilter token="@token1@"/> <replacefilter token="@token2@" value="value2"/> <replacefilter token="@token3@" property="property.key"/> <replacefilter> <replacetoken>@token4@</replacetoken> <replacevalue>value4</replacevalue> </replacefilter> </replace> 更改了maven分隔符(覆盖资源分隔符)。

  

文件过滤用于替换a内的变量字段   归档到其代表的值。对于Assembly插件,大多数   Maven过滤程序,这些变量包含在$ {   和}。例如,在过滤文件之前,它包含   $ {} project.artifactId。但是在过滤完成后,会有一个新文件   用项目的artifactId代替创建   $ {project.artifactId}并且使用这个新文件而不是   原来的。

源: https://maven.apache.org/plugins/maven-assembly-plugin/examples/single/filtering-some-distribution-files.html

或者它可以是Ant的替代品

server_name
  

在文件configure.sh中,替换&#34; @ token1 @&#34;的所有实例。同   &#34; defaultvalue&#34;,&#34; @ token2 @&#34;的所有实例;使用&#34; value2&#34;,以及所有   &#34; @ token3 @&#34;的实例使用属性&#34; property.key&#34;的值,   因为它出现在属性文件src / name.properties中。

源:https://ant.apache.org/manual/Tasks/replace.html