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
2
votes
1 answer

Constructor injection on spring configuration classes

In several code examples I see autowiring used instead of constructor injection. Can any one explain why Constructor injection is difficult but autowiring is possible on spring configuration classes? Thanks in advance. this question does touch the…
Vishal Maral
  • 1,279
  • 1
  • 10
  • 30
2
votes
1 answer

Make Bean depend on list of beans in springboot

I have following @Configuration class, in which I am declaring a @Bean that depends on an @Autowired list of beans. However, this list is not complete when I am accessing to it. All @Bean definitions been executed, except the one defined in the same…
Mayday
  • 4,680
  • 5
  • 24
  • 58
2
votes
0 answers

Changing Spring configuration file name extension .properties to something else

Is there a way to override Spring's default file extension for the properties file? I know that you can change the name with the spring.config.name setting, and the location with the spring.config.location setting, but it still expects the file to…
2
votes
2 answers

Disable / remove spring boot datasource by profile

Using spring boot yaml config, I have a datasource that looks like this: datasource: url: jdbc:postgresql://somehost/somedb username: username password: password hikari: connection-timeout: 250 maximum-pool-size: 1 minimum-idle:…
IVR Avenger
  • 15,090
  • 13
  • 46
  • 57
2
votes
3 answers

Spring - Error Parameter 0 of constructor in Service required a bean of type Configuration that could not be found

I followed tutorial for uploading files but I end up with the following error: Parameter 0 of constructor in nu.pk.cv.storage.FileSystemStorageService required a bean of type 'nu.pk.cv.storage.StorageProperties' that could not be…
Olof
  • 776
  • 2
  • 14
  • 33
2
votes
3 answers

Spring conditional component scan configuration

I have a configuration class which registers beans based on a very simple condition (checking a property value in application.properties). The configuration class and the condition are the following:…
2
votes
0 answers

Spring vs Spring boot reverse proxy troubles

I am working on a project which is kinda old. It is a spring 4 rest server application which uses Jax RS @Path annotations over spring's @RestController annotation. And the default servlet is also Jax Rs's Application. Its weird.. and I have no…
jay
  • 48
  • 7
2
votes
1 answer

Spring security: How can I enable anonymous for some matchers, but disable that for the rest?

I am trying to enable the anonymous access to some part of my rest api, but disable that to the rest. I tried config looks like: @Override public void configure(HttpSecurity http) throws Exception { http.authorizeRequests().anonymous().and() …
Lang
  • 943
  • 13
  • 33
2
votes
1 answer

Openshift secret in Spring Boot bootstrap.yml

This how my bootstrap.yml looks like. spring: cloud: config: uri: http://xxxx.com username: **** password: **** vault: host: vault-server port: 8200 scheme: http authentication: token token:…
Here_2_learn
  • 5,013
  • 15
  • 50
  • 68
2
votes
1 answer

Read @JsonProperty dynamically from config

I am developing a Spring boot application which uses Jackson annotations. I want to read value of @JsonProperty from a config, instead of using constant string. Example JSON input {"s":12} Code I want to read property from my…
2
votes
1 answer

Spring Config profile file is not found

I've created this application-local.json into src/main/resources: { "spring": { "datasource": { "url": "jdbc:postgresql://xxx:yyy/db", "username": "xxx", "password": "xxx", "driverClassName": "org.postgresql.Driver" …
Jordi
  • 20,868
  • 39
  • 149
  • 333
2
votes
2 answers

Create List of enum from comma separated String in Java

I need to create a List of enum from a comma separated String. I have some configurations in properties file which are mainly a list of HttpStatus like: some.config=TOO_MANY_REQUESTS,GATEWAY_TIMEOUT,BAD_GATEWAY This configurations can be bind to a…
Arpan Das
  • 1,015
  • 3
  • 24
  • 57
2
votes
1 answer

Spring ignores `spring.cloud.config.discovery` set as default properties

I'm trying to create Spring Application without referring to any external files. This is supposed to be a module that you'd then include as a dependency, configure and use to plug in the service into an existing ecosystem. This is how I'm doing…
2
votes
1 answer

YAML configuration in spring-core

Is there a way to use YAML configuration without spring boot. From docs its clear it may not be possible but experts may have other opinions.
Raghuveer
  • 2,859
  • 7
  • 34
  • 66
2
votes
2 answers

Spring Application data source configuration from external file

Is it possible to create a data source by reading the values from an external file which is not bundled with WAR in spring application.
1 2
3
11 12