Results 1 to 3 of 3

Thread: MailConfig

  1. #1
    Join Date
    Apr 2011
    Posts
    5

    Default MailConfig

    Hello there
    can someone explain me how to inject mail properties defined unders config/MailConfig.java
    I have an application.properties file generated with my mail.* properties in my target folder
    but it does seem to be injected in the @Value("#{environment['mail.*']}") parameters

    here is the piece of code inquestion
    PHP Code:
    @Configuration
    public class MailConfig {

        @
    Bean
        
    public JavaMailSender mailSender(@Value("#{environment['mail.host']?:'localhost'}"String host,
                @
    Value("#{environment['mail.port']?:25}"int port,
                @
    Value("#{environment['mail.username']}"String username,
                @
    Value("#{environment['mail.password']}"String password
                @
    Value("#{environment['mail.smtp.auth']?:false}"boolean mailSmtpAuth,
                @
    Value("#{environment['mail.smtp.starttls.enable']?:false}"boolean mailSmtpStartTls) {
    ...
        }

    Thanks for your help
    Last edited by pgherveou; Apr 13th, 2011 at 01:24 PM.

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Take a look at the ContainerInitializer (an ApplicationContextInitializer) that sets a profile that includes the application.properties loaded into the environment. Then notice how this initializer is referenced from web.xml.
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    Apr 2011
    Posts
    5

    Default

    thks Keith I shoud have seen that

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •