I want to get a list of protobuf message objects from the Spring boot app. I did manage to get a single protobuf message object from the app but getting a list of them throws exception. My code (simplified). tl;dr create Spring boot app generate class from proto file try return List of generated class objects (RESTful) My code (simplified).
Tag: spring
Is there way to use @Scheduled together with Duration string like 15s and 5m?
I have following annotation in my code At this case I have to have properties like this Propery file looks unreadable because I have calculate value to miliseconds. Is there way to pass value like 5m or 30s there ? Answer As far as I know, you can’t do it directly. However, Spring boot configuration properties do support automatic conversion
How to handle UsernameNotFoundException spring security
How to handle UsernameNotFoundException ? In spring security when username not found the UserDetailsService implementation throws a UsernameNotFoundException. For example like this: I would like to build a custom “User not found REST response”. How should I catch/handle this exception? I have implemented a handler method in the WebSecurityConfigurerAdapter implementation the handler: But this method should wait for an AuthenticationException
Java – Spring Boot: Access-Control- Allow-Origin not working
I tried to implement Access-Control- Allow-Origin in spring boot using few tutorials and this link but not able to implement this. To implement this, in application.properties file, I added below line Which probably means that except the URL https://example.com, no other endpoint can call any APIs. But it’s not working I still can see * in response , in below
Sonar “Make transient or serializable” error
I have the following serializable class (implements serializable): However , it seems like this property is causing some problems with serialization : How can I solve this problem ? Also , is there any downside in not making this transient or serializable ? Will I be able to serialize this class fully ? Answer The Map interface does not extend
Capture setters inside mapper method using AspectJ in Spring
I have java classes like this : I have a mapper method with annotation like this : My FieldPermissionAspect fetches the permission-field mapping from db for a user and sets field to null if user does not have permission for given field. I get a list of string field hierarchy like this : I want to set b, c, d
How to use Criteria in JPA in Spring boot?
I am using JPA and spring boot. I am new to JPA. I want to retrieve an object by passing the value of the function. But in example, it is done through hibernate config. I have not config sessionFactory bean in my classpath. I want to use JPA to retrieve the object. Here in the example, it is: But I
How to remove data source warnings in Spring Jpa and Intellij Idea?
After new update Intellij, I have red warnings in entity classes. For example: I have warning lines under “poll_answers” and “poll_id” “cannot resolve table/column” and offers me press “assign data source”. Answer Your setup: Spring, JPA, ORM Since your Spring project uses JPA and you are defining object-relational-mappings (ORM) using annotations: IntelliJ is intelligent and tries to validate the specified
Spring WebFlux and WebSocket
I am trying to add WebSocket functionality to an existing application which uses Spring WebFlux. It uses: Spring boot 2.2.1.RELEASE Tomcat container Configured to serve jsp pages When I try to connect to it through JavaScript (from inside a jsp page) I am receiving the error “failed: Error during WebSocket handshake: Unexpected response code: 404” I noted that if I
How to fix Spring Security Authorization header not being passed?
In one of my REST services, I make use of Spring Security to validate the token that is being passed in the header. However, spring is unable to find the “Authorization” header, even though it is there. This was not a problem when testing in test, and even locally but when we deployed to PROD we get this issue. As