Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need the <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/index.html?org/springframework/beans/factory/annotation/Value.html" rel="noreferrer"><code>@Value</code></a> annotation.</p> <blockquote> <p>A common use case is to assign default field values using <code>"#{systemProperties.myProp}"</code> style expressions.</p> </blockquote> <pre><code>public class SimpleMovieLister { private MovieFinder movieFinder; private String defaultLocale; @Autowired public void configure(MovieFinder movieFinder, @Value("#{ systemProperties['user.region'] }"} String defaultLocale) { this.movieFinder = movieFinder; this.defaultLocale = defaultLocale; } // ... } </code></pre> <p><strong>See:</strong> <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/expressions.html#expressions-beandef-annotation-based" rel="noreferrer">Expression Language > Annotation Configuration</a></p> <hr> <p>To be more clear: in your scenario, you'd wire two classes, <code>MybeanService</code> and <code>MyConstructorClass</code>, something like this:</p> <pre><code>@Component public class MyBeanService implements BeanService{ @Autowired public MybeanService(MyConstructorClass foo){ // do something with foo } } @Component public class MyConstructorClass{ public MyConstructorClass(@Value("#{some expression here}") String value){ // do something with value } } </code></pre> <p>Update: if you need several different instances of <code>MyConstructorClass</code> with different values, you should <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-autowired-annotation-qualifiers" rel="noreferrer">use Qualifier annotations</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload