spring-boot

Bind .m2 file to docker on build stage

倖福魔咒の 提交于 2021-02-10 20:45:36
问题 I tried build a spring boot project in docker container based on below docker file.But every times all mvn dependency download from internet. How can I bind local .m2 file when i build the docker file. This is my Dockerfile FROM maven:3.5-jdk-8-alpine AS build COPY /src /usr/src/javaspring/src COPY pom.xml /usr/src/javaspring COPY Dockerfile /usr/src/javaspring RUN mvn -f /usr/src/javaspring/pom.xml clean install FROM openjdk:8-jre-alpine COPY --from=build /usr/src/javaspring/target

Caffeine Cache in Spring Boot Cache : Get all cached keys

与世无争的帅哥 提交于 2021-02-10 20:42:30
问题 I'm using Caffeine Cache library for Spring Cache. Is there a way to get all the cached keys? My current application works on a near-realtime data, with the flow as : In the Cache Updater Thread (which runs at a fixed interval, irrespective of the user request), I need to get all the keys currently in the Cache, fetch their latest data from Db & then use @CachePut to update the cache. 回答1: Yo can inject CacheManager and obtain native cache from it. @AllArgsConstructor class Test { private

Caffeine Cache in Spring Boot Cache : Get all cached keys

為{幸葍}努か 提交于 2021-02-10 20:41:48
问题 I'm using Caffeine Cache library for Spring Cache. Is there a way to get all the cached keys? My current application works on a near-realtime data, with the flow as : In the Cache Updater Thread (which runs at a fixed interval, irrespective of the user request), I need to get all the keys currently in the Cache, fetch their latest data from Db & then use @CachePut to update the cache. 回答1: Yo can inject CacheManager and obtain native cache from it. @AllArgsConstructor class Test { private

How to return a List inside this bounded generic method?

大兔子大兔子 提交于 2021-02-10 20:14:21
问题 I have class Response public class Response<T extends ResponseData> { private final T data; //other fields, getters, setters ... } and the empty interface ResponseData: public interface ResponseData { } It takes any object as data but this object must implement the "empty" interface which I created just to force all classes returned inside "data" element be of same super type Now the problem is that I need to return a List inside the data element, but: I don't find it clean to create a

How to send json with GET params via Spring Boot / Tomcat?

人盡茶涼 提交于 2021-02-10 20:10:26
问题 so currently I'm working on a project where we have product objects which in turn contain "Origin" objects (containing region: String and country: String ). What I'm trying to do is a RestController which takes in an optional Origin object and does something with it (e.g. logs it). This is what I have right now: @GetMapping("search") public Page<Wine> getProductByStuff( @RequestParam(required = false) Origin origin, /* other attributes */) { log.info(origin); // it has a proper toString

How to send json with GET params via Spring Boot / Tomcat?

谁都会走 提交于 2021-02-10 20:10:25
问题 so currently I'm working on a project where we have product objects which in turn contain "Origin" objects (containing region: String and country: String ). What I'm trying to do is a RestController which takes in an optional Origin object and does something with it (e.g. logs it). This is what I have right now: @GetMapping("search") public Page<Wine> getProductByStuff( @RequestParam(required = false) Origin origin, /* other attributes */) { log.info(origin); // it has a proper toString

How to send json with GET params via Spring Boot / Tomcat?

左心房为你撑大大i 提交于 2021-02-10 20:07:17
问题 so currently I'm working on a project where we have product objects which in turn contain "Origin" objects (containing region: String and country: String ). What I'm trying to do is a RestController which takes in an optional Origin object and does something with it (e.g. logs it). This is what I have right now: @GetMapping("search") public Page<Wine> getProductByStuff( @RequestParam(required = false) Origin origin, /* other attributes */) { log.info(origin); // it has a proper toString

How create diferents log File with different content using log4 in java configuration

大兔子大兔子 提交于 2021-02-10 20:01:51
问题 i am using spring batch and i need to create different log files one log for job, due to i acces to external properties file, i need to create configuration logs in java code . My canfiguration is ConsoleAppender console = new ConsoleAppender(); console.setLayout(new PatternLayout(stdoutConversionPattern)); console.setThreshold(Level.INFO); console.activateOptions(); Logger.getRootLogger().addAppender(console); // FICHERO: FileAppender1.LOG CONTENDRA LA INFROMACION DE LA EJECUCION DEL

How create diferents log File with different content using log4 in java configuration

走远了吗. 提交于 2021-02-10 20:01:10
问题 i am using spring batch and i need to create different log files one log for job, due to i acces to external properties file, i need to create configuration logs in java code . My canfiguration is ConsoleAppender console = new ConsoleAppender(); console.setLayout(new PatternLayout(stdoutConversionPattern)); console.setThreshold(Level.INFO); console.activateOptions(); Logger.getRootLogger().addAppender(console); // FICHERO: FileAppender1.LOG CONTENDRA LA INFROMACION DE LA EJECUCION DEL

maven fail in spring project build trying to establish connection with database

喜你入骨 提交于 2021-02-10 19:17:29
问题 i make a docker-compose and dockerfile for my spring project, but it fail on maven build stage becouse is trying to establish a connection with the postgres service, I have no idea how I could solve it. this is my docker-compose file: version: '3' services: postgres: build: context: . dockerfile: docker/postgres/Dockerfile restart: always environment: POSTGRES_DB: ${postgres_database} POSTGRES_USER: ${postgres_username} POSTGRES_PASSWORD: ${postgres_password} ports: - '5432:5432' volumes: - .