Questions tagged [spring-bean]

A simple JavaBean managed by the Spring IoC container.

A simple JavaBean managed by the Spring IoC container. These beans are created with the configuration metadata that is supplied to the container, for example, in the form of XML <bean/> definitions or @Bean annotation. Actually, the BeanFactory is the main IoC container which instantiates, configures, and manages these beans. These beans typically have associations with each other, and therefore have dependencies between themselves. These dependencies are configured in the configuration files used by the BeanFactory. Other dependencies that are invisible from the configuration file could be a function of programmatic interactions between beans at run-time.

767 questions
0
votes
0 answers

Can we have space in a bean's id value in spring

I am getting this error: org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: 'duke duke' is not a valid value for 'NCName'. I am using this spring-config.xml: beans…
0
votes
1 answer

Creating multiple bean instances of a class with different property values in spring configuration

I am creating multiple bean instances of a class with different property values in spring configuration. For example:
viswas
  • 1,007
  • 1
  • 9
  • 13
0
votes
1 answer

Grails Spring Security Custom User Details Beans getting overriden

My app architecture is like so: MainWebApp -> CustSecPlugin -> Spring-Security-Core So I have a plugin that I wrap around the spring-security plugins to provide extra implementation that is common across a number of web apps. One of the…
DJOodle
  • 323
  • 2
  • 16
0
votes
1 answer

Spring JavaConfig setter not working

It seems that the setter on my bean is not working. This is my Spring java configuration, SpringConfig.java: @Configuration @ComponentScan("com.xxxx.xxxxx") public class SpringConfig { @Bean(name="VCWebserviceClient") public…
BigJ
  • 1,990
  • 2
  • 29
  • 47
0
votes
1 answer

Dynamic Spring Bean Creation in XML-Based Spring Configuration

I'm using xml-based Spring bean configuration. For certain beans, I want to dynamically load the classes based on the different configs. (I could create a parent class for those classes) Currently I have a workaround solution: use of system…
enfany
  • 875
  • 2
  • 15
  • 33
0
votes
1 answer

AbstractApplicationContext.getBean() return null for registered beans thru prepareBeanFactory

I want to define an MBeanServerConnection dynamically in the spring application context, so I am registering its factory thru prepareBeanFactory(). I can see the bean exists in the context, but when I do getBean(), it returns me null!. Any…
nabsha
  • 168
  • 1
  • 10
0
votes
3 answers

injecting directly to servlet instead of new ClassPathXmlApplicationContext

I have a big java project that contains many servlets. and each servlet needs to get objects from the same bean file using the following command: ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml"); and then I use …
ufk
  • 30,912
  • 70
  • 235
  • 386
0
votes
4 answers

adding datasource to a Jdbctemplate bean throws exception

I'm trying to learn spring and bean configuration. I'm going to have several classes that are gonna DB related functions so each one of them is gonna need to have a JdbcTemplate class. because of that I want to create a bean configuration that will…
ufk
  • 30,912
  • 70
  • 235
  • 386
-1
votes
0 answers

Spring6 upgrade - Autowiring failing in Groovy unit test

I have a passing Spock/Groovy Unit Test in a Spring5 Java application that autowires in a custom com.google.gson.Gson bean: @SpringBootTest(classes = [GsonConfig]) class DeserializerSpec extends Specification { @Autowired Gson gson And the…
Martin Bamford
  • 379
  • 3
  • 13
-1
votes
1 answer

Using JavaPoet to create Sping Beans

I'm working on spring as part of my classwork and using Javapoet for code generation. Is there a way I can create Spring Beans via JavaPoet? I have a use case where I wish to create Java classes based on the configuration and load them up into…
-1
votes
1 answer

Cacheable Annotation in Spring Boot

Service Class import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; @Service public class StudentService{ @Cacheable(value = "student",key = "{#id,#name}") public Student…
-1
votes
1 answer

How to unit test spring bean definitions?

I have defined several spring beans via @Bean. @Bean void SomeClass someClass() { return new SomeClass(); } But these are not covered by unit tests as I use @Mock to mock the classes, and beans are not instantiated in unit tests. Now test coverage…
-1
votes
1 answer

Is BeanPostProcessor postProcessAfterInitialization needed only to work with proxy?

A bean implementing BeanPostProcessor is called when all bean definitions will have been loaded, but no beans will have been instantiated yet BeanPostprocessor is executed after the bean object is created, as it can be executed before init() and…
J.J. Beam
  • 2,612
  • 2
  • 26
  • 55
-1
votes
1 answer

Other ways to create a Bean Factory in Spring Framework

I understand the difference between a BeanFactory and an ApplicationContext. I am also aware that a BeanFactory instance can be created from xml files, which reside in the classpath or anywhere else in the file system. So, an XMLBeanFactory instance…
Sara
  • 603
  • 8
  • 19
-1
votes
1 answer

Getting ClassCastException for @Autowired

I have application where the parent project is updated with the latest Spring library but in the dependent application I do not want to upgrade the spring beans lib version. Since the same dependent application we have to make it compatible with the…