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
0
votes
0 answers

Spring Boot - Access denied unable to connect to MySql DB

I have a fresh Spring Boot application setup. I'm trying to connect to MySql using Liquibase with the configuration below. # Development DataSource # spring: datasource: url: jdbc:mysql://localhost:3306/cstmngtdatabase? …
Junior Frogie
  • 313
  • 1
  • 3
  • 16
0
votes
0 answers

How to get keytab file (file name:Test.keytab) using spring config server to client?

I'm using spring boot application where it has kerberos authentication. For kerberos authentication, we need keytab file to login krb5LoginModule. It is not safe to keep keytab file inside the JAR, so we thought to use spring config server to fetch…
0
votes
0 answers

Why cannot I use @ConfigurationProperties instead of @Value in Spring WebConfig

I want to configure my WebConfig bean to have different CORS origin depending on the profileapplication.properties. For some reason the value in my application-local.properties is not injected into the field of my WebConfig bean. When I use @Value…
xetra11
  • 7,671
  • 14
  • 84
  • 159
0
votes
1 answer

Spring Data JPA Cassandra override save method

I keep getting this message that Spring will override MY factory bean definition with the CassandraRepositoryFactoryBean. This is causing problems as the reason I am overriding the factory is to override the save method on a repo so that I can…
Justin
  • 859
  • 4
  • 15
  • 30
0
votes
2 answers

Caused by: java.lang.IllegalStateException: EntityManagerFactory must not be null

I previously was using Spring Boot 1.4.2.RELEASE and Hibernate 5.0.11.Final, and this was my Database configuration class: @Configuration @EnableTransactionManagement public class DataBaseConfiguration { @Bean(name = "sessionFactory") …
0
votes
1 answer

How provide a different bean implementation to @Autowire field based on annotation?

I have a config class that provides two implemenations of the same base bean interface. I want these to be set on the autowired fields conditionally based on an annotation on the field. public class MyController { @Autowired private…
Don Rhummy
  • 24,730
  • 42
  • 175
  • 330
0
votes
1 answer

Spring conversion service not getting initialized correctly for test

I am using spring boot 1.5.9 to write a small rest server. I have just started of with initialization code and got stuck with this weird behavior. I have a small test - @RunWith(SpringRunner.class) @SpringBootTest public class TestMongo { …
user1676688
  • 414
  • 4
  • 15
0
votes
1 answer

Security Configuration doesn't let me use antMatchers() on some pages

Security Configuration doesn't let me use antMatchers() on some pages. Below is a configuration code where I'm trying to let not signed in user access "/", "/entries", "/signup". With "/signup" there is no problem it let me visit that page, but it…
0
votes
2 answers

Spring Boot: How to use @RestController with a class whose variables come from a properties file

So I'm new to Spring and I'm basically trying to make a REST service for the first time. Some of the data I'd like to return is some data from a properties file. This is my configuration…
0
votes
1 answer

Couldn't pass the @bean value to another class through Autowiring

I am new to spring. So I couldn't figure out what issue is there in the below code. I have two classes. I am defining a @Bean Channel and am autowiring that bean in the next class. I am using annotation for autowiring. When I try "…
0
votes
1 answer

Can I use @ConditionalOnExpression to check for an annotation's property value?

I want to have an annotation where it will pull in a different config class based on the value of property. It might work something like this: (All of this is pseudo code) The annotation: import org.springframework.context.annotation.Import; import…
Don Rhummy
  • 24,730
  • 42
  • 175
  • 330
0
votes
2 answers

Spring Cloud Config server - can't resolve from configuration repository

I am trying to build a set of related services, Discovery, Admin, Config and a plain rest service. REST Service Config Service Underlying git repo where configurations are stored Registry Service Admin service For the purpose of the question, I am…
Nasir
  • 2,984
  • 30
  • 34
0
votes
1 answer

Good practice for placing Spring @Configuration for registering @Beans in context?

I've decided I want to register Spring Beans in the java code and I want to know how it should be done the best way possible. I inject deps through constructor (do not want to use @Autowire - I consider it almost antipattern) and I can make it work…
K. O.
  • 95
  • 2
  • 6
0
votes
1 answer

Can @ConditionalOnProperty use a nested property value?

I want to do something like: @ConditionalOnProperty("${${appname}.someVal}") @Controller public class MyController {...} Where my yaml would have: appname: myapp myapp: someVal: true How would I do this? EDIT: This does not…
Don Rhummy
  • 24,730
  • 42
  • 175
  • 330
0
votes
2 answers

Spring Config Service with Git

I'm going to use Spring Config Service (SCS) for our Microservices Architecture. Currently our Cloud stack is on AWS. Since SCS will run on a Docker, thanks to a Pipeline + Cloud Formation, and our config repository will be on a private GitHub…
abierto
  • 1,447
  • 7
  • 29
  • 57
1 2 3
11
12