Announcement Announcement Module
Collapse

JavaConfig forum decommissioned in favor of Core Container

As described at

http://static.springsource.org/sprin...fig/README.TXT

key features of the Spring JavaConfig project have been migrated into the core Spring Framework as of version 3.0.

Please see the Spring 3.0 documentation on @Configuration and @Bean support:

http://static.springsource.org/sprin...tml#beans-java

For any questions related to @Configuration classes and @Bean methods in Spring 3.0, please post in the dedicated 'Core Container' forum at

http://forum.springsource.org/forumdisplay.php?f=26
See more
See less
Transforming JPA related beans to JavaConfig Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Arul,

    @ExternalValue methods are not registered as beans, so they will not be resolved by trying to reference them with @ExternalBean.

    I understand what you're trying to do here, but it's not supported. Feel free to add a request in JIRA so we can keep tabs on this.

    In the meantime, one option would be to use a base class approach:

    Code:
    @Configuration
    @EnvironmentVariableSource
    public class BaseConfig {
        protected @ExternalValue("database_type") String databaseType;
    }
    
    @Configuration
    public class ConcreteConfig extends BaseConfig {
        public @Bean Foo beanThatNeedsDatabaseType() {
            return new Foo(this.databaseType);
        }
    }

    Comment


    • #17
      Also, please post any future new questions in a new forum thread so that others can easily find answers to similar questions.

      Comment


      • #18
        Thanks Chris. I will post my further questions in new forum thread.

        Comment


        • #19
          Created a JIRA for this issue: jira.springframework.org/browse/SJC-198

          Thanks!
          Arul

          Originally posted by Chris Beams View Post
          Arul,

          @ExternalValue methods are not registered as beans, so they will not be resolved by trying to reference them with @ExternalBean.

          I understand what you're trying to do here, but it's not supported. Feel free to add a request in JIRA so we can keep tabs on this.

          In the meantime, one option would be to use a base class approach:

          Code:
          @Configuration
          @EnvironmentVariableSource
          public class BaseConfig {
              protected @ExternalValue("database_type") String databaseType;
          }
          
          @Configuration
          public class ConcreteConfig extends BaseConfig {
              public @Bean Foo beanThatNeedsDatabaseType() {
                  return new Foo(this.databaseType);
              }
          }

          Comment

          Working...
          X