I am following this example here:- http://www.baeldung.com/spring-graphql
for me the GraphQLSchema bean is not getting autoregistered. it throws me this error:-
No qualifying bean of type 'graphql.schema.GraphQLSchema' available
my Pom file has all requried Spring boot dependecies:-
graphql-spring-boot-starter
graphql-java-tools
graphiql-spring-boot-starter
I have following settings in application.proerties:-
graphql.root=/v1
graphql.servlet.mapping=${graphql.root}/graphql
graphql.servlet.enabled=true
graphql.servlet.corsEnabled=true
Not sure what am I missing, Do I need to explicitly define this bean as on this page:- https://github.com/graphql-java/graphql-spring-boot/blob/master/example/src/main/java/com/embedler/moon/graphql/boot/sample/ApplicationBootConfiguration.java.
But I thought it will autocreate for me, I just need to have *.graphqls on my class path.
I have followed the same tutorial as well and encountered the same error. I ended up figuring out what the issue was and it is that you need to add #Component to the Query class that the tutorial describes.
Once that was done graphiql was finally finding the schema and the /graphql end-point was exposed.
Related
I am new to springboot.
Doing a migration of my service (kotlin)following a guide written at work.
Got this weird exception and cannot find any documentation.
Parameter 3 of method multipleOpenApiResource in org.springdoc.webflux.core.MultipleOpenApiSupportConfiguration required a bean of type 'org.springdoc.core.GenericResponseService' that could not be found.
Action:
Consider defining a bean of type 'org.springdoc.core.GenericResponseService' in your configuration.
Should I define this bean at my #Configuration?
Is this a symptom of dependency missing or bad dependency wiring?
One of my beans was called ResponseBuilder and it conflicted with spring boot.
Sorry for the trouble
I have a spring boot app that worked fine up until I updated from 1.2.0.M1 to 1.2.0.M2. The app will not build because of an UnsatisfiedDependencyException resulting from spring-boot RabbitAutoConfiguration:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'jmsMessagingTemplate' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$MessagingTemplateConfiguration.class]:
Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.amqp.rabbit.core.RabbitTemplate]: :
No qualifying bean of type [org.springframework.amqp.rabbit.core.RabbitTemplate] is defined:
expected single matching bean but found 3: looperTemplate,pingTemplate,orgRequestTemplate; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException:
No qualifying bean of type [org.springframework.amqp.rabbit.core.RabbitTemplate] is defined:
expected single matching bean but found 3: looperTemplate,pingTemplate,orgRequestTemplate
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:751) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:466) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
The problem is I do have RabbitMQ templates, but I have 3 of them and it needs a qualifier to select a single template. However this code is in spring-boot, not my code. I would prefer not to have to alter spring-boot code, but I am not sure what I should do in my code to prevent this exception.
I can see the offending jmsMessagingTemplate was added in the 1.2.0.M2 version. The naming of this is also misleading as I do not have JMS enabled in my app (although this is a RabbitMQ specific auto configuration file in spring-boot).
Any suggestions on how I can configure my code without eliminating templates or modifying spring-boot code?
I've created #1701 to track the naming issue. You should read rabbitMessagingTemplate there.
There are several auto configuration instances in Boot that requires certain types to be flagged with #Primary if they're not using the "default" name. For instance a JdbcTemplate is created for you automatically if none exists and a datasource is present. If you have more than one you should either name one dataSource or flag one of them as #Primary.
In your case, the messaging auto config for RabbitMQ expects one RabbitTemplate to be named rabbitTemplate or flag one of the three as #Primary.
This is annoying and we should do better. I've created #1702 for that.
Let me know if that works out for you. Thanks!
In spring integration and other spring derivatives, xml elements(tags) are used to simplify spring configuration files by defining element to bean class mapping.
I am interested to know where the mapping between the xsd:element and bean class is actually defined?
Everything goes to NamespaceHandler
Here is a manual: Extensible XML authoring
Note: in the link above /current/ path always goes to current Spring release
after Proguard obfuscation i get the following error :
Unexpected exception parsing XML document from ServletContext resource
[/WEB-INF/applicationContext.xml]; nested exception is
java.lang.IllegalStateException: Annotation-specified bean name 'a'
for bean class [com.company.project.b.a.a.a] conflicts with existing,
non-compatible bean definition of same name and class
[com.company.project.a.a]
i'm using annotation based spring configuration , how can i avoid having two classes with the same name using Proguard because Spring doesn't allow two beans to have the same name.
I'm not sure if this is what you want, but you can specify bean name in #Component (and stereotypes #Repository, #Service and #Controller) value:
#Component("myBeanName")
public class MyBean {
}
I had the same problem and nothing else was helping out. Sometimes the problem occurs if you have moved your classes around and it refers to old classes, even if they don't exist.
In this case, just do this :
mvn eclipse:clean
mvn eclipse:eclipse
This worked well for me.
Another cause; you may have different versions of Spring in your classpath, for example, spring 2.x with spring 3.x. In such condition, beans seem to be loaded twice. If you use maven, check if a module does not import an old version of Spring (mvn dependency:tree) and remove it by excluding the involved spring artifact (exclusions).
I am trying to add REST support to my Spring 3 + Hibernate application.
I have created the REST support using the wizard from Netbeans, at it has put a #Autowire annotation (not #autowired) above my Resource class. Getting the #Autowire annotation from Spring causes the error
incompatible types
found : org.springframework.beans.factory.annotation.Autowire
required: java.lang.annotation.Annotation
Getting #Autowire from JAX-RS should be only for Spring 2.5 as far as I understand from here. I get the following error if I include it, which I think is related to Spring 2.5 being loaded:
SEVERE: Exception while loading the app : java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception
parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml];
nested exception is java.lang.NoSuchMethodError:
org.springframework.beans.MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/
Object;)Lorg/springframework/beans/MutablePropertyValues;
Could someone point me on how to add this annotation, and make JAX-RS work with Spring? Also, I was using a SessionFactory and the autogenerated code refers to a entityManagerFactory in the applicationcontext. Can those be used interchangingly?
PS: Allow me to say that I hate Java EE with a passion so far in my three week journey with the platform, major stumbling blocks at every level, sorry for the rant.
You are using the wrong Autowire. The 'Netbeans REST wizard' looks like it would be using com.sun.jersey.api.spring.Autowire (last image, very bottom of page), and from your message above, you are using org.springframework.beans.factory.annotation.Autowire which appears to be an Enum used in Spring 2.0.
From what I can tell, this may be a specific thing to Spring 2.0 anyways. Perhaps you should take a look at doing the REST JAX-RS stuff yourself (using Jersey), as it is not that difficult.