To configure the datasors I use two classes with the annotation @Configuration . I collect the project maven. How can I tell mavena to take one datasors class in a production profile and another for a maiden?

UPD: in wildfly in the standalone.conf file I specify -Dspring.profiles.active=production , when starting the server I see that the option is registered in java_opts, then the application deployment and press enable, the operation crashes with org.jboss.msc.service.DuplicateServiceException: Service jboss.pojo.\"org.jboss.netty.internal.LoggerConfigurator\".DESCRIBED is already registered"}}

  • one
    It only comes to my mind to create two versions of configs activated through profiles for the activation condition. Read more - here: habrahabr.ru/sandbox/27207 I didn’t do that myself, to be honest. - DimXenon
  • 2
    Use Spring Profiles - enzo

1 answer 1

As advised by fellow @enzo - use Spring Profiles

There everything is very simple - you hang up the annotation with the profile name on the config and specify the profile either at launch (preferable) or by specifying via web.xml, as comrade @ ZNK-M tells here.

  • When starting a maven build? I hung @Profile annotations on my configs. Are they synchronized with the maven profile? - cadmy
  • When I run mvn clean install -Pproduction, I still get an error with a delay - cadmy
  • @cadmy spring profiles have nothing to do with maven profiles and are not related to them. but you can specify the desired profile in the web.xml and in the mavenovo build, slip web.xml with the desired profiles. those. we have dev-web.xml in which is specified by the active profile dev, prod-web.xml in which the active profile is specified by production, and at the time of assembly we put the necessary xml'nik. although it seems to be considered bard practice. - Victor
  • You wrote "at startup", at startup what did you mean? - cadmy
  • one
    Added the profile "-Dspring.profiles.active = production" to standalone.conf in JAVA_OPTS - cadmy