• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Spring Boot - specify concrete class in configuration properties.

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Say I have a class


and I want to configure it with a bunch of concrete classes that implement ItemInterface...

Is it possible to specify the class of each item in application.yaml?

Something like



I should say, this is not something I can handle with profiles.
Ultimately this list will contain a different set of concrete classes per product deployment, so I would want to externalise it.
 
Saloon Keeper
Posts: 29001
214
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you resolve it with this?

https://coderanch.com/t/790679/frameworks/Spring-boot-externalise-bean-configuration
 
Marshal
Posts: 6206
501
IntelliJ IDE Python TypeScript Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kinda sounds like you're trying to solve a programming problem with a build management tool.

Alternatively could you inject the right kind of "items" into your class based on some kind of configuration like an environment variable?
 
John Farrel
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did it by loading the config via ImportResource, using an xml bean definition (which lets you choose the concrete classes)
 
Evacuate the building! Here, take this tiny ad with you:
The new gardening playing cards kickstarter is now live!
https://www.kickstarter.com/projects/paulwheaton/garden-cards
reply
    Bookmark Topic Watch Topic
  • New Topic