apache / apache/rocketmq-spring

RocketMQTemplate injection faild

Open
#406 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.3k
Forks
943
PR merge metrics
No merged PRs in 30d

Description

this is the error log. when i use `bootstrap.yml`. RocketMQAutoConfiguration not injection RocketMQTemplate;
if use `application.yml` replace `bootstrap.yml` will be succeed;
i don't know why not use `bootstrap.yml`?

```
2021-11-21 00:07:14.198 INFO 13196 --- [ main] org.example.SpringbootDemoApplication : Starting SpringbootDemoApplication on rom1c with PID 13196 (D:\workspace\springboot-demo\target\classes started by admin in D:\workspace\springboot-demo)
2021-11-21 00:07:14.200 INFO 13196 --- [ main] org.example.SpringbootDemoApplication : No active profile set, falling back to default profiles: default
2021-11-21 00:07:14.831 INFO 13196 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-11-21 00:07:14.837 INFO 13196 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-11-21 00:07:14.838 INFO 13196 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.38]
2021-11-21 00:07:14.915 INFO 13196 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-11-21 00:07:14.916 INFO 13196 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 687 ms
2021-11-21 00:07:14.950 WARN 13196 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'produderController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.rocketmq.spring.core.RocketMQTemplate' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
2021-11-21 00:07:14.952 INFO 13196 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-11-21 00:07:14.960 INFO 13196 --- [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-11-21 00:07:15.032 ERROR 13196 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean of type 'org.apache.rocketmq.spring.core.RocketMQTemplate' that could not be found.

The following candidates were found but could not be injected:
- Bean method 'rocketMQTemplate' in 'RocketMQAutoConfiguration' not loaded because @ConditionalOnBean (types: org.apache.rocketmq.client.producer.DefaultMQProducer; SearchStrategy: all) did not find any beans of type org.apache.rocketmq.client.producer.DefaultMQProducer

Action:

Consider revisiting the entries above or defining a bean of type 'org.apache.rocketmq.spring.core.RocketMQTemplate' in your configuration.

Disconnected from the target VM, address: '127.0.0.1:62492', transport: 'socket'

Process finished with exit code 1
```

`bootstrap.yml`
```
server:
port: 8081
spring:
application:
name: producer

#producer
rocketmq:
name-server: 127.0.0.1:9876
producer:
group: task-produer
send-message-timeout: 300000
compress-message-body-threshold: 4096
max-message-size: 4194304
retry-times-when-send-async-failed: 0
retry-next-server: true
retry-times-when-send-failed: 2
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.