Will Spring support CDI? [closed]

Even though Spring is open source and used and supported by a large community, its future development is controlled by a single company (spring source / vmware). As such, its decisions are inherently non-public and certainly influenced by a large number of factors – like the currents demands of the community, but certainly also financial … Read more

Mock external server during integration testing with Spring

After playing a bit with various scenarios, here is the one way how can one achieve what was asked with minimal interventions to the main code Refactor your controller to use a parameter for thirdparty server address: @RestController public class HelloController { @Value(“${api_host}”) private String apiHost; @RequestMapping(“/hello_to_facebook”) public String hello_to_facebook() { // Ask facebook about … Read more

Not annotated parameter overrides @??? parameter

Explanation Although I can’t reproduce this on AbstractItemCountingItemStreamItemReader from this artifact implementation group: ‘org.springframework.batch’, name: ‘spring-batch-core’, version: ‘4.1.2.RELEASE’ , this annotation means that the parent method has some @NotNull / @NonNull annotation on the parameter, while the overriding method has no. To fix it, you need to put the same annotation on the overriding method. … Read more

Configure Spring Boot with two ports

As is has been mentioned before, server.port and management.port along with management.context-path properties could be set to make the embedded container to listen on different ports (management-related properties to access Actuator endpoints). To listen on ports other than server.port and management.port: @Configuration public class EmbeddedTomcatConfiguration { @Value(“${server.additionalPorts}”) private String additionalPorts; @Bean public EmbeddedServletContainerFactory servletContainer() { … Read more

No WebApplicationContext found: no ContextLoaderListener registered?

You’ll have to have a ContextLoaderListener in your web.xml – It loads your configuration files. <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> You need to understand the difference between Web application context and root application context . In the web MVC framework, each DispatcherServlet has its own WebApplicationContext, which inherits all the beans already defined in the root WebApplicationContext. … Read more

Error: Maximum response size reached get method Json object along with file part (Spring boot rest api)

This is a Postman specific error and it is generated because there is a Max Response Size limit available in the settings. By default it is 50 MB. Which means, Postman will fail the request if the response size exceeds 50 MBs. Since, you are receiving JSON data along with file part or file base64 … Read more

Spring @Bean(name =”name”) vs @Bean @Qualifier(“name”)

Yes there is a difference: @Bean(“foo”) (or @Component(“foo”)) gives your bean the name “foo” in the Spring Context, whereas @Qualifier(“foo”) only adds information without changing the name of the bean. As the bean name is the bean’s unique identifier in the Context, you can only have 1 bean named “foo”, whereas you can have multiple … Read more

tech