Pls, help. Can’t run my application on ubuntu 18.04.5 Java version: openjdk 11.0.10 2021-01-19 Apache Maven 3.6.0 Maven home: /usr/share/maven Java version: 11.0.10, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: “linux”, …
Tag: spring-boot
Can I choose to include/exclude what controller is deployed per environment in Spring Boot?
I would like to expose an endpoint only to certain TEST environment and leave it out altogether in PROD. I will have a separate @RestController for this endpoint. My question is how to ensure this endpoint is accessible only from the test env and never in production? I tried to play around with @ComponentScan…
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast or BeanUtils.copyProperties not working
am new to JPA and springboot unable to get the api response when am using @Query param(I try achieve the inner join) Repositoty class: Service class: am getting the ” [Ljava.lang.Object; cannot be cast ” exception after that I have changed to as below: service class foreach added the Object but fo…
How do I load environment variables to load application context before integration test runs
I’m working on multi-module maven project using Spring Boot 2.4.0. I have written integration tests for a module. The test class looks similar to this. To run the SpringApplicationClassWithMainMethod.class i.e., in order to load the Application context I need few environment variables that I set in ecli…
How do you test a reactive mongo repository?
I’m trying to test the findByPhoneNumber method in this repository ATM, my test looks like this When I run it, I get this error org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘io.freesale.repository.UserRepositoryTest’: Unsatisfied dependency …
Not able to update table contents through postman using Spring Boot
Repository is configured like this This is another class I’m able to post the topics in my table and get as well from the postman but when I try to use put, to update the contents of the table, nothing changes. I was trying to put the below command to update the table where “javascript” was …
Error com.fasterxml.jackson Deploy .WAR Spring Boot in JBoss/Wildfly
ERROR [org.springframework.boot.web.servlet.support.ErrorPageFilter] (default task-22) Forwarding to error page from request [/api/method] due to exception [com.fasterxml.jackson.annotation.JsonFormat$Value.hasLenient()Z]: java.lang.NoSuchMethodError: com.fasterxml.jackson.annotation.JsonFormat$Value.hasLenie…
Spring security : How to use @RolesAllowed with @RequestBody
I have a method like this: Request looks like this: Now only certain roles are allowed to access “data_type=A”. I want to use @RolesAllowed or equivalent to block the request based on @RequestBody How should i achieve this? Tx in advannce Answer If you want to filter based on request value, you ca…
Error accessing field by reflection for persistent property [model.Credentials#email] on @EmbeddedID
I’ve been experiencing problems implementing the Authorities on my spring boot application, and after digging a little I realised that maybe the association between my Credentials and Authorities tables, was wrong. In fact it come to my attention that Spring allowed every type of user, (regardless their…
Spring Security: redirect to single page app in case of 401
When I type into browser any route of my React app, for example: http://localhost/login, the request hits my server, and my server responds with 401 Unauthorized. When request is not an authorized backend api I’d like to handle the request in my react routing. WebSecurityConfig.java: RestAuthenticationE…