Skip to content
Advertisement

Tag: spring-boot

Cant run my spring application on ubuntu with jdk11

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”, version: “5.4.0-66-generic”, arch: “amd64”, family: “unix” There is app output: pom.xml: UserService.java RegistarionCotroller.java WebSecurityConfig.java Answer When initializing the WebSecurityConfig, Spring Container will attempt to

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 for the above code am getting null values BeanUtils.copyProperties

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 eclipse. So, in order to run the above integration test while loading the SpringApplicationClassWithMainMethod.class

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 expressed through field ‘repository’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘io.freesale.repository.UserRepository’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:

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.hasLenient()Z at com.fasterxml.jackson.datatype.jsr310.deser.JSR310DateTimeDeserializerBase.createContextual(JSR310DateTimeDeserializerBase.java:104) at com.fasterxml.jackson.databind.DeserializationContext.handleSecondaryContextualization(DeserializationContext.java:685) at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:446) Answer – Create file named jboss-deployment-structure.xml – Add the below block – Copy file in location WEB-INF/jboss-deployment-structure.xml IMG – Preview project Maven

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 can use @PreAuthorize. Docs: https://docs.spring.io/spring-security/site/docs/current/reference/html5/#method-security-expressions Some examples: https://www.baeldung.com/spring-security-method-security

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 authority) to access ever method, even the ones I though have been secured.

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: RestAuthenticationEntryPoint.java: Is there a way to forward the request to index.html in RestAuthenticationEntryPoint? Answer I’ve

Advertisement