java - Default Spring bean when profile is not present -


i'm using spring mvc controllers, , i'd make request-mapped methods available during development. can using spring profiles:

@controller @profile("!dev") public class defaultcontroller {  }  @controller @profile("dev") public class devcontroller extends defaultcontroller {  } 

but ideally, i'd rather not pollute production classes' code annotations referring 'dev' profile.

i think maybe it's possible using primary annotation, can't work. this post seems should work:

@controller public class defaultcontroller {  }  @controller @profile("dev") @primary public class devcontroller extends defaultcontroller {  } 

but when that, spring tries load both controllers when starts under 'dev' profile, , fails with

org.springframework.beans.factory.beancreationexception: error creating bean name 'org.springframework.web.servlet.mvc.method.annotation.requestmappinghandlermapping#0' ... there 'defaultcontroller' bean method 

is want possible? if so, how can it?

the problem here class devcontroller inherits defaultcontroller. keep classes separate. don't extend devcontroller defaultcontroller if contents same.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -