Questions tagged [spring-context]

95 questions
1
vote
0 answers

Why does Spring Framework consider method names only for deciding if a bean can be skipped?

Background I came across a piece of code that looks something like this - public class TestClass { @Profile("profile") @Bean(name = "beanMethodName") //I know this is not an accurate way of adding qualifier public Function
1
vote
1 answer

@PropertySource doesn't override properties defined in application.properties

If any property is defined in application.properties, it cannot be overridden by re-defining it in other .properties files using the @PropertySource annotation. This bug is only valid if the original value is present in application.properties. Any…
1
vote
0 answers

Regarding adding context to Junit test case

@Service public class MyRegistry { private final Map services; @Autowired public MyRegistry(List msgList) { this.services = msgList.stream().collect(Collectors.tounmodifiableMap(CustomClass:: getId,…
NewDevs
  • 11
  • 1
1
vote
0 answers

Separating Contexts of Spring Boot Applications for Integration Testing

I need to do integration testing on an ecosystem of spring boot based services. Most of these communicate with each other via REST APIs and use their own databases. Besides, there is some additional stuff that needs to be done in the test cases:…
Florian
  • 11
  • 2
1
vote
0 answers

java.lang.NoSuchMethodError: 'void org.springframework.expression.spel.support.StandardTypeConverter.(java.util.function.Supplier)'

I moved my application to spring 5.3.14 and facing below error org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is java.lang.NoSuchMethodError: 'void…
VKR
  • 195
  • 4
  • 18
1
vote
0 answers

Scheduled task was not triggered after DST

I am using a scheduled task with annotation: @Scheduled(cron = "0 30 0 * * ?", zone = "Europe/Bratislava") This task was successfully triggered every day, but after the Daylight saving time (DST) change, the task did not start on 2022/03/28 at 0.30…
ifc0
  • 11
  • 1
1
vote
0 answers

Profile activation based on available environment variables or any custom condition

I was reading this article from Spring Boot Blog and following section attracted attention. Cloud Platform Activation If you only want volume mounted config trees (or any properties for that matter) to be active on a specific cloud platform, you…
abcdef12
  • 1,033
  • 1
  • 11
  • 22
1
vote
1 answer

Is there any annotation equivalent of "default-lazy-init" attribute in Spring Framework?

How can I set this attribute in my JavaConfig application context?
toiepp
  • 85
  • 6
1
vote
0 answers

Is it possible to use Spring Retry with TestNg Spring context

I have TestNg tests and use AbstractTestNGSpringContextTests: @ContextConfiguration(classes = ContextConfiguration.class) public class BaseTest extends AbstractTestNGSpringContextTests { ....... } And enabled retry in my config…
1
vote
1 answer

How to avoid a second Instantiation of a spring bean in child test context

I created an Embedded Sftp server bean for my integration tests, i hooked the startup and the shutdown of the server respectively with the afterPropertiesSet and destroy life cycles public class EmbeddedSftpServer implements InitializingBean,…
user17375469
1
vote
1 answer

Spring Context doesn't seem to recognize a Bean when creating it with stereotype annotations. Throws NoSuchBeanDefinitionException

I'm following a book to learn some modules of the Spring ecosystem. Currently trying to create beans using stereotype annotations. I've written a simple Java class and marked it as a component: package main.parrot; @Component public class Parrot { …
1
vote
0 answers

Create bean using spring xml

How to create xml bean for the below java class. I am using old spring version, from where i need to create a xml bean for the following "TestSample" class. @Service @EnableConfigurationProperties(SampleProperties.class) public class TestSample{ …
user2000189
  • 479
  • 4
  • 6
  • 22
1
vote
0 answers

Is there a reliable way to determine the type of a non-singleton bean by its name?

I have the name of a bean of unknown scope. I'm trying to determine its static type (the class annotated with @Component, or the return type of the @Bean factory method) in a reliable way (that deals with proxies etc). BeanFactory.getType(beanName)…
kaqqao
  • 12,984
  • 10
  • 64
  • 118
1
vote
1 answer

Spring context is not getting updated even after using DelegatingSecurityContextAsyncTaskExecutor

I ran into some problem with spring contexts and it's really made more confusing after reading all the articles. So, here it is my use case: I have an application running which needs user's authentication token passed in the request to use it in the…
1
vote
1 answer

How to inject Spring boot Environment bean to Custom Spring xml bean?

I created a bean using spring boot @Configuration class annotation like below @Configuration public class CustomConfiguration { @Bean public MyEnvironmentProcessor myEnvironmentProcessor(Environment env) { return new…
sujin
  • 2,813
  • 2
  • 21
  • 33