spring-boot

Make Jackson Subtypes extensible without editing the Supertypes java-file

£可爱£侵袭症+ 提交于 2021-02-08 05:29:20
问题 In my company we have a fixed JSON message structure: { "headerVal1": "" "headerVal2": "" "customPayload": { "payloadType":"" } } I would like to have some kind of library, which allows me, to not care for the company defined message structure, and instead just send and receive the payload. My idea was, to define the structure of the company template as one object, and use subtypes of a PayloadObject . @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.MINIMAL_CLASS,

Is it possible to use a custom serializer/deserializer for a type by default in spring?

好久不见. 提交于 2021-02-08 05:25:32
问题 I have a type from a third party library ( JSONB from jooq) that I've written a custom serializer/deserializer for: @JsonComponent public class JSONBSerializer extends JsonSerializer<JSONB> { @Override public void serialize(JSONB jsonb, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeString(jsonb.toString()); } } @JsonComponent public class JSONBDeserializer extends JsonDeserializer<JSONB> { @Override public JSONB deserialize

Spring Security add filter to all Endpoint EXCEPT one

被刻印的时光 ゝ 提交于 2021-02-08 05:18:40
问题 I researched this and found this Answer on SO. I do however have the complementary question to this one: I have a set of filters, that i want to be applied to ALL requests, EXCEPT special cases (eg.: all paths except /mgmt/** and /error/**). This cannot be done using the same method presented in the linked answer, as I would add the filters to the default http-security Object, which would then apply for the special cases too. is there a thing like "negative matchers", allowing me to do

SpringBoot maven build war using specific application.properties

断了今生、忘了曾经 提交于 2021-02-08 05:09:00
问题 I have a Spring Boot application with has three application.properties files : application.properties application-qa.properties application-prod.properties I want build a war using maven by using one of the properties depending on the environment the application with be deployed too i.e dev , qa or prod . How can I do this. I'm pretty new to Spring Boot. 回答1: Setting the SPRING_PROFILES_ACTIVE environment variable will activate the intended profile. for example, in order to activate the qa

SpringBoot maven build war using specific application.properties

自作多情 提交于 2021-02-08 05:04:44
问题 I have a Spring Boot application with has three application.properties files : application.properties application-qa.properties application-prod.properties I want build a war using maven by using one of the properties depending on the environment the application with be deployed too i.e dev , qa or prod . How can I do this. I'm pretty new to Spring Boot. 回答1: Setting the SPRING_PROFILES_ACTIVE environment variable will activate the intended profile. for example, in order to activate the qa

Read Spring boot property inside listener

末鹿安然 提交于 2021-02-08 04:39:45
问题 My requirement is, I need to initialize some application resources when server is started in spring boot. In order to initialize those resources, I need bunch of properties. So, I have kept those properties in external property file and I am trying to read the properties in my custom listener when spring boot is started. The problem is, I could not get any property values in the listener. I am able to read them after application started without any issues. But, I need them inside listener

What causes Spring scheduler to execute before the application and servlet starts up?

跟風遠走 提交于 2021-02-08 04:26:25
问题 I have a simple Spring-Boot web application with some scheduling tasks: @SpringBootApplication @EnableScheduling public class Application extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(final SpringApplicationBuilder app) { return app.sources(Application.class); } public static void main(String[] args) { SpringApplication.run(Application.class, args); } } And a service executing two scheduling tasks: @Service public class SchedulingService {

SpringBoot rabbit connection timeout issue

六月ゝ 毕业季﹏ 提交于 2021-02-08 04:26:16
问题 My spring boot application throws connection timeout error, and it is never able to connect. The other interesting problem I see is, it is never picking up the connection timeout property defined in spring app properties. org.springframework.amqp.AmqpTimeoutException: java.util.concurrent.TimeoutException at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:74) ~[spring-rabbit-1.6.7.RELEASE.jar:na] at org

Spring Boot Actuator /env endpoint returning data as XML - why?

丶灬走出姿态 提交于 2021-02-08 04:11:14
问题 We have several Spring Boot apps running as microservices. Each of them are running spring boot actuator to allow us to monitor /metrics, /env, /health, etc. On just one of these services the /env endpoint is returning data as XML when requested in the browser. Further, the XML is invalid, but what I really care about is getting the endpoint to return data in json. The reason the XML is invalid is because we are using Spring Cloud Config and the first element contains the GitHub URL which

Spring Boot Actuator /env endpoint returning data as XML - why?

别说谁变了你拦得住时间么 提交于 2021-02-08 04:10:40
问题 We have several Spring Boot apps running as microservices. Each of them are running spring boot actuator to allow us to monitor /metrics, /env, /health, etc. On just one of these services the /env endpoint is returning data as XML when requested in the browser. Further, the XML is invalid, but what I really care about is getting the endpoint to return data in json. The reason the XML is invalid is because we are using Spring Cloud Config and the first element contains the GitHub URL which