spring-boot

OAuth2 | ClientCredentialsResourceDetails | deprecated

牧云@^-^@ 提交于 2021-02-11 15:40:33
问题 I am new to spring security, and i come across to implement OAuth2 with client_credentials as Grant type. i am using below piece of code, but i am getting suggestion that ClientCredentialsResourceDetails, OAuth2RestTemplate & OAuth2AccessToken are deprecated. Can someone help with the alternate to this ? private String getAuthTocken(){ final ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails(); resourceDetails.setClientId("ceapiClientId"); resourceDetails

Use of @OneToMany or @ManyToMany targeting an unmapped class exception occuring

烈酒焚心 提交于 2021-02-11 15:36:10
问题 I am creating my first Spring-Boot-Starter-data-jpa project. I was following a tutorial on that and creating a separate application in same way. When I am starting my Spring Boot application , I am getting org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is org

Starting Spring boot REST controller in two ports

若如初见. 提交于 2021-02-11 15:35:21
问题 Is there a way to have two rest controller running on two different ports from one spring boot application ? Say for example Controller_A running in http://localhost:8080 and Controller_B running in http://localhost:9090 in one SpringBoot main Application ? 回答1: One way of doing this is actually creating two application properties; app-A.properties server.port=8080 app-B.properties server.port=9090 And then in your controllers, put annotation like below; @Profile("A") public class ControllerA

Use of @OneToMany or @ManyToMany targeting an unmapped class exception occuring

倾然丶 夕夏残阳落幕 提交于 2021-02-11 15:33:59
问题 I am creating my first Spring-Boot-Starter-data-jpa project. I was following a tutorial on that and creating a separate application in same way. When I am starting my Spring Boot application , I am getting org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is org

Use of @OneToMany or @ManyToMany targeting an unmapped class exception occuring

可紊 提交于 2021-02-11 15:33:27
问题 I am creating my first Spring-Boot-Starter-data-jpa project. I was following a tutorial on that and creating a separate application in same way. When I am starting my Spring Boot application , I am getting org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is org

Test endpoints compliance against openapi contract in Spring Boot Rest

谁都会走 提交于 2021-02-11 15:24:58
问题 I am looking for a nice way to write tests to make sure that enpoints in Spring Boot Rest (ver. 2.1.9) application follows the contract in openapi contract. In the project I moved recently there is following workflow: architects write contract openapi.yml and developers have to implement endpoint to compliance the contract. Unfortunately a lot of differences happen and this test have to catch such situation and it is not possible to change this :( I was thinking about the solution to generate

@Transactional not working when i throw exception on next line

牧云@^-^@ 提交于 2021-02-11 15:14:34
问题 I don't understand the below behavior: I have a method: @Transactional public void processRejection(final Path path) { try { //some code here } catch (final Exception e) { this.handleException(e)); } } which calls the below which does a saves an entity which doesn't yet exists in the database: void handleException(final Throwable e) { this.filesMonitoringJpaManager.save(someEntityHere); throw new Exception(...) } Now the strange is when I comment the throw new Exception(...) the save works,

Spring REST endpoint returning StreamingResponseBody: AsyncRequestTimeoutException after 30 seconds

烈酒焚心 提交于 2021-02-11 15:14:32
问题 I have the same problem as described here and here. I tried the answers given and combinations thereof but none solved my issue. When I tried this answer, after 30 seconds, instead of the timeout, the download restarted from the beginning and then, after 30 more seconds, then it timed out. I'm testing by visiting the REST endpoint in Google Chrome and trying to download a file from there. Here I have the project that displays this error. Thanks in advance. Edit: here's the source: src\main

Spring boot Webservice / Microservices and scheduling

≯℡__Kan透↙ 提交于 2021-02-11 15:13:19
问题 I am having a spring boot application which exposes REST APIs and also am planning to add a spring boot scheduled task. The purpose of task is to pick up some pending 'reservations' from data store which is momgodb and process it. Now the question is when multiple instances of service running, there is high probability all the nodes will pick up same 'reservation records'. I was looking at mongodb lock for this and was checking updateAndModidy / transactions (in 4.x) of mongodb. Also

@Transactional not working when i throw exception on next line

故事扮演 提交于 2021-02-11 15:13:09
问题 I don't understand the below behavior: I have a method: @Transactional public void processRejection(final Path path) { try { //some code here } catch (final Exception e) { this.handleException(e)); } } which calls the below which does a saves an entity which doesn't yet exists in the database: void handleException(final Throwable e) { this.filesMonitoringJpaManager.save(someEntityHere); throw new Exception(...) } Now the strange is when I comment the throw new Exception(...) the save works,