About Michel

Hi, My name is Michel Meeuwissen. I'm a proud member of the JDriven company. JDriven gives me the opportunity to develop efficient software for the most interesting companies in the Netherlands. Based on historical projects I'm focused on the Spring framework and front-end technologies. Besides my coding skills I also like to learn more about full stack development. You are able to contact me by LinkedIn.

Posts by Michel

Introduction to Spring profiles

Posted on by  
Michel Meeuwissen

So many men, so many minds. When we are implementing software for different customers we sometimes need to handle various requirements for the same project. For example Customer A needs SAML authentication and customer B needs LDAP authentication. With Spring Profiles (available from Spring 3.1) we are able to provide a way to segregate parts of our implemented application configuration. This blog will help us to make certain code or rather certain Spring beans only available for specific requirements. For example the example used in this blog can be used to activate the required authentication provider for the provider manager when using Spring Security. Profiles can be configured by annotations and/or by xml. Annotations @Component or @Configuration annotated beans can contain the annotation @Profile to only load them in a certain environment.

@Component
@Profile("ldap")
public class LDAPAuthentication {
   public LDAPAuthentication() {
      System.out.println("LDAP Authentication set by annotations");
   }
}

@Component
@Profile("saml")
public class SAMLAuthentication {
   public SAMLAuthentication() {
      System.out.println("SAML Authentication set by annotations");
   }
}

Continue reading →

shadow-left