Questions tagged [spring-config]

Refers to the org.springframework.context.annotation package of the Spring Framework that moves bean definition and Spring configuration out of XML file and into Java classes via annotations.

Questions referring to @Configuration and @Bean will be the primary source of questions for this tag.

Useful Links

178 questions
33
votes
4 answers

Spring Boot: Multiple similar ConfigurationProperties with different Prefixes

I'm using Spring Boot and have two very similar services which I'd like to configure in my application.yml. The configuration looks roughly like this: serviceA.url=abc.com serviceA.port=80 serviceB.url=def.com serviceB.port=8080 Is it possible to…
nioe
  • 756
  • 1
  • 7
  • 15
21
votes
3 answers

What is the loading precedence for properties from Spring Cloud Config?

Spring has an explicit order for the loading of externalized configurations. Devtools global settings properties on your home directory (~/.spring-boot-devtools.properties when devtools is active). @TestPropertySource annotations on your…
I-Lin Kuo
  • 3,220
  • 2
  • 18
  • 25
17
votes
5 answers

@RefreshScope and /refresh not working

I have tried to implement spring external configurations using Config Server. It is working fine for the very first time when the application is started but any changes to the properties file are not being reflected. I tried to use /refresh endpoint…
ASD
  • 325
  • 1
  • 2
  • 9
16
votes
2 answers

Spring Data Page doesn't serialize Sort to JSON correctly

This issue appeared in Spring-Data release 2. In latest version 1.13.9 (and older) it works fine. Controller code: @RestController public class HelloController { @RequestMapping("/") public String index() { return "Greetings from…
Oleg Danyliuk
  • 201
  • 2
  • 6
14
votes
3 answers

Prevent Spring Batch automatic job trigger after context creation without Spring Boot

I am setting up a project with Spring Batch without using Spring Boot. When the Spring application context is created, all the jobs get executed. I tried adding spring.batch.job.enbled=false to the application.properties to prevent this but it still…
12
votes
4 answers

How to prevent Spring Config to reset my local git repository to origin/master

I am using Spring Config to share in a git server the configuration for some Spring Boot microservices. It works great but when I am traveling I have to work offline sometimes. I have configured Spring Config microservice local profile to get the…
icordoba
  • 1,834
  • 2
  • 33
  • 60
8
votes
2 answers

How can I create many kafka topics during spring-boot application start up?

I have this configuration: @Configuration public class KafkaTopicConfig { private final TopicProperties topics; public KafkaTopicConfig(TopicProperties topics) { this.topics = topics; } @Bean public NewTopic…
ip696
  • 6,574
  • 12
  • 65
  • 128
7
votes
1 answer

How to handle a modular spring project with flyway and single db

Situation I have a modular Spring Boot project. As a database schema manager, I would like to use Flyway. As already stated, the project is modular. This is, because there will be different configurations which use different modules. This means,…
Herr Derb
  • 4,977
  • 5
  • 34
  • 62
7
votes
1 answer

Apply /refresh on multiple instances annotated with @refreshScope

I'm writing spring boot application, which using spring configuration, deployed on pivotal cloud foundry and exposed by Netflix Eureka as discovery serivce / load balancer. I have created a bean as…
Yuval Simhon
  • 1,439
  • 2
  • 19
  • 34
6
votes
1 answer

Is relaxed binding in Spring really unsupported for @Value annotations?

We use environment variables to configure various properties in Spring Boot applications. I found that binding a environment variable FOO_BAR_BAZ via @Value(${foo.bar.baz}) works out of the box in Spring Boot 1.4.3.RELEASE / Spring…
wwerner
  • 4,227
  • 1
  • 21
  • 39
5
votes
1 answer

How can I make a REST controller conditional on the environment?

We have a use case where we want a set of endpoints to be enabled in every environment except the production environment. Rather than implementing a custom security implementation for this use case, our idea was to use a variation of Spring's…
mgzwarrior
  • 53
  • 1
  • 6
5
votes
1 answer

What is the order of Spring Boot bean creation and dependency injection?

I was working on a project on Spring Boot 1.5. It had the following type of configuration class: @Configurtion public class Foo{ @Autowired private DependencyA dependencyA; @Bean public DependencyA getDependency(){ return new…
4
votes
1 answer

Custom file names in Spring Cloud Config Server

How to specify a spring boot application to access only a specific .properties file among other files in my Spring Cloud Config Server. My Spring Cloud Config has the following…
padmanabhanm
  • 315
  • 3
  • 15
4
votes
1 answer

Spring Security - POST method for antMatcher (not antMatchers)

I have two configuration: @Order(1) @Override protected void configure(HttpSecurity http) throws Exception { http.antMatcher("/api/**") .authorizeRequests() .anyRequest().hasRole("USER") .and() .httpBasic() …
AppiDevo
  • 3,195
  • 3
  • 33
  • 51
4
votes
2 answers

Use spring session JDBC with existing database (not springboot)

I have my application running with spring web mvc framework without spring boot. Now I want to use spring session JDBC to store the session to the database used by the app. All the examples I found online are using spring boot, and if not using…
Muhammad Kholid B
  • 478
  • 1
  • 10
  • 25
1
2 3
11 12