1926

Create Spring Bean where class is a string?

Question:

Is there some kind of bean factory or static class that I can use within a Spring configuration file to create an instance of a Java class and set its properties? Something like this:

<bean id="myThingy" class="org.whatever.specialBeanMaker"> <property class="${maven.filtered.property.value}" /> <properties> <property name="a" value="...." /> <property name="b" value="...." /> <property name="c" value="...." /> </properties> </bean>

In other words, I need to make a bean from a class I won't know until runtime (because of filtering, JNDI, propertyPlaceholderConfigurer, etc.

Answer1:

No need for anything special. Just do it like you'd expect:

<bean class="${whateverClass}"/>

Recommend

  • How to call BeanFactoryPostProcessor.postProcessBeanFactory method when use Spring with XML configur
  • JPA CDI Injecting DAO into an Entity
  • What is the likely cause of a net::ERR_CONNECTION_ABORTED when uploading a file to Spring
  • Updating Dojo provide
  • Display validation errors inside
  • gspread or such: help me get cell coordinates (not value)
  • Should I or shouldn't I use the CachingConnectionFactory with hornetq 2.4.1
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • SplFileObject error failed to open stream: No such file or directory
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • Highlight one bar in a series in highcharts?
  • Q promise. Difference between .when and .then
  • Cross-Platform Protobuf Serialization
  • How can I use Kendo UI with Razor?
  • Why winpcap requires both .lib and .dll to run?
  • Calling of Constructors in a Java
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to format a variable of double type
  • Comma separated Values
  • PHP: When would you need the self:: keyword?
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Load html files in TinyMce
  • Error creating VM instance in Google Compute Engine
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • C# - Getting references of reference
  • How to set the response of a form post action to a iframe source?
  • Hits per day in Google Big Query
  • coudnt use logback because of log4j
  • how does django model after text[] in postgresql [duplicate]
  • Change div Background jquery
  • How to stop GridView from loading again when I press back button?
  • Qt: Run a script BEFORE make
  • JaxB to read class hierarchy
  • reshape alternating columns in less time and using less memory
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal