天道酬勤,学无止境

spring-boot

How to set logging.path for spring-boot apps?

spring-boot provides several logging.* settings that can be applied in application.properties, like: logging.level.=DEBUG logging.file=myfile.log logging.path=d:/logs/ Problem: myfile.log is generated, BUT inside the classpath! Why isn't spring taking my absolute path into account?

2021-06-15 15:32:58    分类:问答    java   spring   spring-boot

Spring boot: accessing command line args from a bean

I run spring boot application with a single argument - filename. The file contains some properties I need in runtime. When the application starts it checks if args.length==1 But I need this file (properties) in a single point - @Component annotated bean. Is it a way to get an access to the file's content from it?

2021-06-15 15:09:39    分类:问答    java   spring-boot   properties

SpringBoot: FeignClient with SSL (p12)

I'm trying to create a FeignClient for one external HTTP API which uses SSL. The struggle is - how to modify default Spring FeignClient with my logic, in this case SSL Connection Factory. So basically I wanna keep all the good things Spring automatically does for the FeignClients, like Hystrix, Sleuth tracing, etc and make it work with my SSL factory. Will appreciate any suggestions. Here is what I tried to do: I've tried to provide a custom @Configuration outside of ComponentScan: @Configuration public class CustomFeignConfiguration { @Bean public Feign.Builder feignBuilder() { Client

2021-06-15 14:21:56    分类:问答    java   ssl   spring-boot   spring-cloud   Feign

org.gradle.api.internal.LocationAwareException from gradle

I have a gradle build error from the following gradle file. But I am clueless why it failed. Please advise. Thanks, buildscript { repositories { maven { url "http://repo.spring.io/libs-snapshot" } mavenLocal() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:1.0.0.RC4") } } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'spring-boot' <== This is line 14 jar { baseName = 'gs-spring-boot' version = '0.1.0' } repositories { mavenCentral() maven { url "http://repo.spring.io/libs-snapshot" } } dependencies { // tag::jetty[] compile("org

2021-06-15 13:03:55    分类:问答    gradle   spring-boot

MapStruct add a new calculated field to the dto

I'm trying to map an entity Order to a OrderDTO using MapStruct. I want to add to OrderDTO a new field total, this field is not available in the original entity Order and should be calculated using the information available in the Order (order entries price, quantity, taxes...). I created a new field total in the OrderDTO and I'm trying to map it by adding a default method to the mapper interface: public interface OrderMapper { ... default BigDecimal orderToTotal(Order order){ return logicToCalculateTotal(); } } When I lunch the build MapStruct launch the error Unmapped target property: "total

2021-06-15 12:52:47    分类:问答    spring-boot   java-8   mapstruct

Is there a “revert” to Spring @DependsOn annotation?

I need one Component to be initialized before another. With @DependsOn it would look something like this: @Component("beana") public class BeanA{ @PostConstruct void init(){ // do smth } } @Component("beanb") @DependsOn("beana") public class BeanB{ @PostConstruct void init(){ // do smth } } I now have to tell BeanB that it depends on the initialization of BeanA. My problem is that I do not want BeanB to know about BeanAs existance (e.g, when BeanB is just publishing Events in an EventBus while initializing and BeanA handles these events). I would like to use an annotation at BeanA stating it

2021-06-15 12:33:41    分类:问答    java   spring   spring-boot

org.hibernate.MappingException: The increment size of the sequence is set to [10] in the entity mapping while … size is [1]

We run into a problem when updating to Spring Boot 2.2 and the associated Hibernate 5.4.x. We do have the following sequence generator @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "hilo_sequence_generator") @GenericGenerator( name = "hilo_sequence_generator", strategy = "...", parameters = { @Parameter(name = "sequence_name", value = "XXX_SEQUENCE"), @Parameter(name = "initial_value", value = "1"), @Parameter(name = "increment_size", value = "10"), @Parameter(name = "optimizer", value = "hilo") }) private Long id; With the update to SB 2.2 / HB 5.4 we get the following

2021-06-15 12:17:10    分类:问答    hibernate   spring-boot   id-generation

Spring Boot Actuator - Cannot disable /info endpoint

I tried disabling all actuator endpoints for production environment in application.yml configuration file: endpoints.enabled: false It works for all endpoints except for /info. How can I turn off all endpoints for given environment? UPDATE: Project I am working on is also acting as Eureka client. In documentation for Spring Cloud Netflix in section Status Page and Health Indicator (http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html) it says that "Eureka instance default to "/info" and "/health" respectively". Is there any solution to disable those endpoints? I was able to

2021-06-15 12:07:29    分类:问答    java   spring-boot   spring-boot-actuator

Vaadin + Spring Boot errors: “Cannot enhance @Configuration” and “More than one Servlet Mapping defined”

I'm new to Spring and Vaadin. I'm trying to go through tutorial for views navigation. I'd like to enable @Push in future to update views periodically with data fetched from DB. The project is very, very simple. I use no configuration class nor any XML - only Java annotations. Could anyone help me to fix the example code? Because I'm getting following warnings and I'm not sure what can be done with it and what will be the result of ignoring them. First one is: onClassPostProcessor : Cannot enhance @Configuration bean definition 'com.vaadin.spring.VaadinConfiguration' since its singleton

2021-06-15 11:47:54    分类:问答    java   spring   spring-boot   vaadin   vaadin-push

Is there a way to integrate java bean validation api With Spring RestTemplate

Is there a way to integrate spring RestTemplate with JavaBean validation api. ? I know there is a integration for spring controller. you can put @Valid on request body param and if Employee is not valid you will get MethodArgumentNotValidException exception . which you can handel in exception handler class. @PostMapping(value = "/add", produces = APPLICATION_JSON_VALUE) public ResponseEntity<String> addEmployee( @RequestBody @Valid Employee emp) { //... } But what I want is similar way to validate response from spring restTemplate like when I call this way - I want to get same(or maybe other)

2021-06-15 11:32:37    分类:问答    java   spring   spring-mvc   spring-boot   bean-validation