Posts

Showing posts from August, 2017

Override Server Port while execution

$ java -jar -Dserver.port=8082 event-service.jar

How spring cloud config use local property override remote property

spring:   profiles: default   cloud:     config:       allowOverride: true       overrideNone: true       server:         bootstrap: true         git:           uri: file://${user.home}/config  both should reside on config server side, and if I understand correctly, spring.cloud.config.allow-override=true allows system properties from client side to override config server values right? The problem I'm facing now is I'm trying to have a local prop on config client side to override the same prop from config server, let's say config server: key=valueA In which file (like bootstrap.properties, application.properties or else) should I put on client side key=valueB so that client will use valueB for this key? Yes -------------------- define following properties in git repo (as a source for config-server) [for given profile]:   spring.cloud.config:   ...

Application.yml - bootstrap.yml - prioroty

bootstrap.yml is loaded before application.yml. It is typically used for the following: when using Spring Cloud Config Server, you should specify spring.application.name and spring.cloud.config.server.git.uri inside bootstrap.yml some encryption/decryption information Technically, bootstrap.yml is loaded by a parent Spring ApplicationContext. That parent ApplicationContext is loaded before the one that uses application.yml. ------------------------------------------------------------------- bootstrap.yml or bootstrap.properties It's only used/needed if you're using Spring Cloud and your application's configuration is stored on a remote configuration server (e.g. Spring Cloud Config Server). Note that the bootstrap.yml or bootstrap.properties can contain additional configuration (e.g. defaults) but generally you only need to put bootstrap config here. Typically it contains two properties: location of the configuration server (spring.cloud.config.uri) name of the application ...

info endpoint - application.yml

info:   build:     artifact: '@project.artifactId@'     name: '@project.name@'     description: '@project.description@'     version: '@project.version@' Note:  value should not start with any token like @ pom.xml:  (build)         (resources)             (resource)                 (directory)src/main/resources(/directory)                 (filtering)true(/filtering)             (/resource)         (/resources)         (plugins)             (plugin)

Cannot get maven project.version property in a Spring application with @Value

After some research and trials on how to get the maven project version in a Spring Boot application I couldn't find anything working for me. Using a manifest is definitively a rotten path due to class loaders issues, i.e. one gets the first manifest Spring finds, which in my case was not the one of my application. One solution I have found is to use the maven resources plugin to "filter" (replace) properties in resource files. In this case the Spring application.properties. Below are the steps to make this work. In the pom, activate resources filtering with the following definition:     (resources)         (resource)             (filtering)true(/filtering)             (directory)src/main/resources(/directory)             (includes)                 (include)application.properties(/include)            ...

How can I specify the default JVM arguments for programs I run from eclipse?

Yes, right click the project. Click Run as then Run Configurations. You can change the parameters passed to the JVM in the Arguments tab in the VM Arguments box. That configuration can then be used as the default when running the project. Go to Window → Preferences → Java → Installed JREs. Select the JRE you're using, click Edit, and there will be a line for Default VM Arguments which will apply to every execution. For instance, I use this on OS X to hide the icon from the dock, increase max memory and turn on assertions: -Xmx512m -ea -Djava.awt.headless=true Go to Window → Preferences → Java → Installed JREs. Select the JRE you're using, click Edit, and there will be a line for Default VM Arguments which will apply to every execution. For instance, I use this on OS X to hide the icon from the dock, increase max memory and turn on assertions: -Xmx512m -ea -Djava.awt.headless=true

difference between EnableEurekaClient and EnableDiscoveryClient

There are multiple implementations of "Discovery Service" (eureka, consul, zookeeper). @EnableDiscoveryClient lives in spring-cloud-commons and picks the implementation on the classpath.   GENERIC @EnableEurekaClient lives in spring-cloud-netflix and only works for eureka. If eureka is on your classpath, they are effectively the same. SPECIFIC

service-discovery-eureka-cloud-foundry

Image
Eureka server It is really easy to use Eureka with Spring Boot. The first thing you need to start is obviously the server: Go to  https://start.spring.io/ , add  Eureka Serve r to the list of dependencies and generate the project.   Import the project in your IDE Open  EurekaApplication.java  and add  @EnableEurekaServer . It should look like this: 1 2 3 4 5 6 7 8 @SpringBootApplication @EnableEurekaServer public class EurekaApplication {      public static void main ( String [ ] args ) {          SpringApplication . run ( EurekaApplication . class , args ) ;      } } Add the following lines to  application.yml  to configure the server: (I prefer YAML, but it is also possible to use  application.properties  which is provided by the project from the Spring Initializer) 1 2 3 4 5 6 7 8 9 10 server :    port : 8761 spring :    applic...