I am new to Spring Boot, and I am wondering about this error message.
I am trying to create a GraphQL class to connect to various GraphQL configurations, and I want to pass a value to the constructor (for my class path, ultimately):
public class ArticleResource {
@Autowired
GraphQLService graphQLService = new GraphQLService("classpath:articles.graphql");
... other code
}
public class GraphQLService {
public GraphQLService(String value) {
System.out.println(value);
}
... other code with @Autowired & @PostConstruct annotations
}
I am using an example of how to connect GraphQL to Spring Boot, and I have several places where the annotation @Autowired is used as well as @PostConstruct. I feel like one of those is leading to the problem I am seeing.
The full error is as follows:
Description:
Parameter 0 of constructor in com.project.api.graphql.service.GraphQLService required a bean of type 'java.lang.String' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'java.lang.String' in your configuration.
How would I solve this? Am I not able to use a custom constructor with Autowired or PostConstruct annotations?