Questions tagged [spring-boot]
Use the Spring Boot tag for questions related to spring boot framework and the features it brings to your Web application. This includes questions about configuration, embedding of the Web servers, setting up metrics, health checks, externalized configuration etc. It does not include questions about the Web server itself, Java code running in your application, or standard spring components. Tag these questions with its own tags to get the best response!
spring-boot
67,027
questions with no upvoted or accepted answers
22
votes
1
answer
19k
views
Gradle archive contains more than 65535 entries
I am integrating hadoop2.5.0 for running mapreduce job and spring-boot-1.2.7 release and getting error while including this
Archive contains more than 65535 entries.
My gradle jar dependency
jar {
...
15
votes
0
answers
772
views
Django channels with Spring Boot Websockets (StompSession) do not work
Hey there we want to use Django just to execute python code and use channels for the results. Implemented everything the websockets are not working as they should. If I try to send something from our ...
14
votes
2
answers
6k
views
How to ignore EI_EXPOSE_REP2 in case of spring autowired components
In my Spring Boot application, I use com.github.spotbugs:spotbugs-maven-plugin plugin. The spotbugs check reports no issues on following class:
@Service
public class FooService {
@Autowired
...
14
votes
1
answer
2k
views
Working example of Spring Cloud Gateway with Redis session management?
Can you please point out any written or video tutorial of working example of spring-cloud-starter-gateway? Using spring-session-data-redis, Spring Boot 2 and possibly related libraries e.g. spring ...
14
votes
1
answer
2k
views
How to migrate code from Spring Security to Reactive Spring Security?
I'm trying to migrate classic Spring Boot Application to Reactive Spring Boot Application, but I have a problems with this task.
How to migrate the code below
package com.example;
import org....
14
votes
2
answers
7k
views
Spring Security Caused by: org.springframework.security.config.annotation.AlreadyBuiltException: This object has already been built
In my spring boot application, When I add @PreAuthorize("hasAuthority('ADMIN')") on service layer class which is injected into UserDetailService implementation Class, I get an error "This object has ...
13
votes
2
answers
3k
views
Hibernate 6.1.5.Final unable to determine table reference
Hello StackOverflow Community,
Attempted:
Upgrading Spring Boot from 2.7.5 to 3.0.0, which uses Hibernate ORM core version 6.1.5.Final
Entity
Plant.java
@Data
@Entity
public class Plant {
@Id
...
13
votes
1
answer
2k
views
How to set up a cache fallback in SpringBoot when unable to connect to Redis?
There is a SpringBoot (v2.2.7) application, where a Redis cache is configured
fragment of pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>...
13
votes
4
answers
5k
views
Required request part 'file' is not present - Angular2 Post request
I am trying to get my file upload functionality done using Angular2 and SpringBoot. I can certify that my java code for the file uploading working fine since I have tested it successfully using ...
12
votes
1
answer
374
views
Register SPI dynamically at runtime
I'm attempting to create a custom implementation of java.nio.FileSystem for an existing Application.
The implementation itself seems to work correctly within its context.
However, the parent ...
12
votes
1
answer
8k
views
Failed to bind properties under 'server.port' to java.lang.Integer
Some time ago I faced with such issue:
Failed to bind properties under 'server.port' to java.lang.Integer:
Property: server.port
Value: $PORT
Origin: "server.port" from property ...
12
votes
1
answer
1k
views
QueryDsl MongoDB - Accessing Deeply Nested Object for Query
I have issues trying to access nested object when using BooleanBuilder. I have read that the default is 2 levels, but for my use case, I need to access 3rd level nested objects. So I have added @...
12
votes
1
answer
3k
views
How to generate Swagger UI from javadocs?
I can generate swagger UI on my Spring boot application from @Api @ApiOperation, @ApiResponses annotations.
These annotations makes code a bit dirty. I wonder, how I can generate swagger ...
12
votes
2
answers
930
views
Using redis and elasticsearch concurrently, but it errors with "availableProcessors is already set to [4], rejecting [4]"
ERROR:Factory method 'elasticsearchClient' threw exception; nested exception is java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]
I just want to use redis and ...
11
votes
0
answers
2k
views
Server Sent Event (SseEmitter) - Broken pipe when timeout
The SSE using SseEmitter of SpringBoot 2.6.3 is working well, but when there is a timeout, the following error appears :
org.apache.juli.logging.DirectJDKLog - : Changing async state from [STARTED] ...
11
votes
0
answers
7k
views
What is the cleaner and efficient way of implementing health check for Kafka in my spring boot application?
I have a spring boot (2.1.6) application that both consumes and produces messages to a (organization wide) common kafka instance. I am trying to implement health checks for this kafka broker in my ...
11
votes
0
answers
2k
views
EC2 Instance - Sending STDOUT logs to Cloud Watch
Reading the 12factor app in the logging chapter, it suggests that the application logs should be sent to STDOUT.
I found plenty of documentation on how to get the logs from STDOUT and send it to ...
11
votes
0
answers
1k
views
Getting "com.mongodb.MongoInternalException: The responseTo in the response does not match the requestId in the request" while connecting to mongodb
My app is using Spring-Boot framework. Everything was working fine until GC overhead error occurred. GC error was recovered but mongodb connection was giving this error continuously after it. But at ...
11
votes
1
answer
5k
views
How to shutdown application context between tests
I have 3 groups of tests: unit, integration, acceptance.
Latter two groups launches ApplicationContext: minimal for "integration" and full for "acceptance".
Both application contexts register queue ...
11
votes
3
answers
16k
views
How to get the version of Spring Boot in the /info actuator endpoint
It's possible to include the version of Spring Boot in the banner.txt by adding ${spring-boot.version}.
How can I do the same for the /info actuator endpoint?
I've tried adding both of the following ...
11
votes
3
answers
2k
views
Alternative for org.apache.commons.mail.util.MimeMessageParser compatible with Jakarta on Java 17
As I updated my Spring Boot application to Java 17 and Spring Boot 3, I migrated from Java EE to Jakarta. I used the MimeMessageParser of org.apache.commons.mail.util.MimeMessageParser, but it expects ...
11
votes
1
answer
6k
views
Can I use @MockBean to mock a bean in just one method of my test class?
I have this mvc test class
@RunWith(SpringRunner.class)
@SpringBootTest
public class UserTest {
private MockMvc mockMvc;
@Resource
private WebApplicationContext webApplicationContext;
...
10
votes
1
answer
12k
views
Spring boot 3 upgrade: java.lang.NoClassDefFoundError: org/springframework/util/SocketUtils
Looks like SocketUtils is deprecated now as a part of spring boot 3 upgrade. While running controller tests, I am getting below error. Anyone have come across it and how was it solved?
main] o.s.test....
10
votes
1
answer
7k
views
Spring Boot testing: Cannot bind @ConfigurationProperties - Ensure that @ConstructorBinding has not been applied
In a Spring Boot unit test, how can you mock @ConstructorBinding @ConfigurationProperties data class?
Setup
Both
Kotlin 1.4.30 (for unit tests and config classes)
Java 15 (with --enable-preview) (...
10
votes
0
answers
3k
views
Spring boot context load test hangs
We have a Spring Boot app written in Kotlin. The problem is it hangs during Maven clean test while running context load test below.
Java: 14.0.1
Kotlin: 1.4.20
Spring boot:2.3.6.RELEASE
Spring cloud:...
10
votes
1
answer
2k
views
Spring context indexer not working for dependency jar
I have some library jar lib.jar (made using spring boot but packaged as normal jar without spring boot plugin) which is made of spring boot and contains spring.components file generated by spring-...
10
votes
2
answers
3k
views
SpringBoot hibernate gradle byte code enhancement
I am trying to mane hibernate OneToOne relationships work lazily.
My setup is spring-data-jpa using hibernate and Gradle.
Even this is a well-documented problem/feature and there is a lot of good ...
10
votes
1
answer
3k
views
Kafka Connect with Spring Framework
Is anyone aware of any Spring Boot integration with Kafka Connect? There is a spring-kafka project that I think gives a nice integration with Kafka clients but not connect and streams APIs.
10
votes
0
answers
3k
views
Spring Boot, Tomcat & Gradle: xalan & serializer jars not found
Yesterday I tried to merge some single spring boot projects into one new project and since then I am getting the following errors in my ide console when starting the project:
Ignoring Class-Path ...
10
votes
0
answers
1k
views
Configuring custom Json Serializer for Spring controller test
I'm testing a controller:
@RestController()
public class MessagesController {
...
}
Using @WebMvcTest annotation:
@RunWith(SpringRunner.class)
@WebMvcTest(value = {MessagesController.class})
public ...
10
votes
2
answers
4k
views
How to restart a SimpleMessageListenerContainer
I try to connect to a RabbitMQ with spring boot. The connection should always restart/retry the connection. I have a problem reconnecting after a fatal exception. The application can never loose a ...
10
votes
0
answers
5k
views
Performance problems with Redis/Spring Data Redis
I have a performance problem in my Spring Boot application when it's communicating with Redis that I was hoping someone with expertise on the topic could shed some light on.
Explanation of what I'm ...
10
votes
1
answer
2k
views
Spring Cloud Netflix Zuul, CSRF and Form Submission
I have some problems with Spring Cloud and CSRF protection.
I secured my application (a gateway and a sign up service) with Spring Cloud Security, OAuth2 etc.
I granted access to everyone (permitAll) ...
10
votes
0
answers
10k
views
Error when deploying a Spring Boot Websocket/STOMP application on WebLogic 12.2.1
I am creating a Spring Boot REST API that leverages WebSockets/STOMP to send messages to an Angular front end using SockJS. I have gone through great lengths to get the application to deploy in ...
10
votes
1
answer
3k
views
Spring Boot: Secured RESTful API using Spring Social and Spring Security
I am trying to define and secure a RESTful API using Spring Boot. Ideally, I would like to use Spring Social and allow clients (web and mobile) to login via Facebook.
What is working
So far, I ...
10
votes
2
answers
27k
views
Dispatcher Servlet in Spring Boot
In my Spring Boot application with packaging type as war, I am configuring Spring MVC. As I understand we don't have to configure Dispatcher Servlet manually. However, I old style of web.xml I used to ...
9
votes
0
answers
352
views
KafkaException: jdk.internal.loader.ClassLoaders can’t find org.apache.kafka.common.security.plain.PlainLoginModule
Caused by: org.apache.kafka.common.KafkaException: javax.security.auth.login.LoginException: No LoginModule found for org.apache.kafka.common.security.plain.PlainLoginModule
at org.apache.kafka....
9
votes
1
answer
5k
views
Unknown wrap conversion requested after migrating to spring boot 3
I am getting below exception for a jpa query
org.springframework.orm.jpa.JpaSystemException: Unknown wrap conversion requested: java.util.ArrayList to java.lang.string: 'org.hibernate.type.descriptor....
9
votes
1
answer
9k
views
Spring boot 3 issue with micrometer tracing with handling Traceparent header
I have below code which handle requests from other apps which pass the traceId through Traceparent header. I expect it will hydrate the parent traceId from the request, and in zipkin dashboard I ...
9
votes
0
answers
2k
views
How can I prevent Micrometer from adding _total suffix to Counter metric name
In my code I define my custom (counter) metric as follows:
Counter.builder("request_count")
.tags("method","GET")
.tags("path","/my/...
9
votes
0
answers
2k
views
Custom Async Executor with Tracing in Spring Boot 3
I'm migrating a Spring Boot project to version 3. The project uses asynchronous task and tracing.
Following the documentation on Micrometer GitHub wiki, we tried to define the Async executor like that:...
9
votes
0
answers
5k
views
How to enable JPA auditing with SpringBootTest?
I want to write integration tests for my RestAPI endpoints, and I'm struggling with @EnableJpaAuditing. I want some of my entities to be audited by Spring, so I've created the following configuration ...
9
votes
1
answer
2k
views
WebFluxSecurity does not add Authentication to SecurityContext
I have this strange issue with Spring Cloud Security with the reactive stack. I setup Spring Cloud Gateway and at the same time, I made it be a RsourceServer so all incoming requests will have JWT ...
9
votes
1
answer
1k
views
Spring Boot/Data: Generic service class for crud operations
Let's say I want to create a REST API which performs basic CRUD operations on several entities. For that I've created generic interface:
public interface CrudService<T>{
//generic CRUD ...
9
votes
1
answer
5k
views
Self-Update a Spring-Boot Application
What i am trying to do is writing a self-updating Spring Boot 2.2.5 application
I wrote a little spring-boot-starter-web application with a RESTController to control the update process (i know the ...
9
votes
0
answers
6k
views
Spring RestTemplate - getting java.io.EOFException: null and Error parsing HTTP request header when execute simple GET request
I want to execute a GET through an endpoint in my own application using RestTemplate but when I do I am getting these error / exception:
o.apache.coyote.http11.Http11Processor : Error parsing HTTP ...
9
votes
0
answers
4k
views
ActiveMQ Embedded web console and Spring Boot
According to this documentation I must be able to access ActiveMQ console by the following url: http://localhost:8161/console
I use ActiveMQ in embedded mode via my Spring Boot application. ActiveMQ ...
9
votes
1
answer
494
views
Spring boot - running integration tests in interactive mode
When developing a web application SpringBoot dev tools module is handy for speeding up the compile and run loop. However, I could not find any similar feature for integration tests.
More specifically,...
9
votes
1
answer
2k
views
Creating a delegating authentication provider (Spring Security)
I am trying to create a Delegating authentication provider to do logic before deciding on which authenticationProvider to choose based on some arbitrary logic; for the sake of this example, if the ...
9
votes
0
answers
1k
views
kotlin-reflect with proguard causes reflection errors
I'm using ProGuard for my spring boot application code. After I upgraded to Spring Boot 2, I cannot start my application anymore.
Spring Boot 2 uses kotlin-reflect to create beans, which uses kotlin....