在我的春季启动aws-cloud SNS http终点确认订阅无效。当我的应用程序出现错误后SNS确认。 错误:
[Request processing failed; nested exception is java.lang.IllegalArgumentException: Invoked method public abstract void org.springframework.cloud.aws.messaging.endpoint.NotificationStatus.confirmSubscription() is no accessor method!] with root cause
java.lang.IllegalArgumentException: Invoked method public abstract void org.springframework.cloud.aws.messaging.endpoint.NotificationStatus.confirmSubscription() is no accessor method!
at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
at org.spring
我的控制器处理程序是:
@NotificationSubscriptionMapping
public void handleSubscriptionMessage( NotificationStatus status) throws IOException {
//Confirming SNS subscription
status.confirmSubscription();
}
我的Pom包含以下内容:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-aws-messaging</artifactId>
<version>1.0.4.RELEASE</version>
</dependency>
<!-- For Spring AWS autoconfiguration-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-aws-autoconfigure</artifactId>
<version>1.0.4.RELEASE</version>
</dependency>
我按照link
中的说明进行了操作答案 0 :(得分:1)
您是否指定了自定义解析器:
<mvc:annotation-driven>
<mvc:argument-resolvers>
<ref bean="notificationResolver" />
</mvc:argument-resolvers>
</mvc:annotation-driven>
<aws-messaging:notification-argument-resolver id="notificationResolver" />
另外,我看不到控制器映射,但在教程中有一个声明:
目前无法在方法上定义映射URL 因此,必须在类型级别完成RequestMapping 包含端点的完整路径。
答案 1 :(得分:0)
为那些在java配置之后的人提供此功能。请注意,您必须使用NotificationMessageHandlerMethodArgumentResolver来实现HandlerMethodArgumentResolver。
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.aws.messaging.endpoint.NotificationMessageHandlerMethodArgumentResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
@Autowired
private NotificationMessageHandlerMethodArgumentResolver notificationResolver;
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(notificationMessageHandlerMethodArgumentResolver());
}
@Bean
public NotificationMessageHandlerMethodArgumentResolver notificationMessageHandlerMethodArgumentResolver () {
return new NotificationMessageHandlerMethodArgumentResolver();
};
}
答案 2 :(得分:0)
我的 Kotlin 配置看起来像这样,配置订阅和消息传递以及取消订阅方法参数解析
import com.amazonaws.services.sns.AmazonSNS
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.aws.messaging.endpoint.config.NotificationHandlerMethodArgumentResolverConfigurationUtils
import org.springframework.context.annotation.Configuration
import org.springframework.web.method.support.HandlerMethodArgumentResolver
import org.springframework.web.servlet.config.annotation.EnableWebMvc
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@Configuration
@EnableWebMvc
class ListenerWebConfiguration : WebMvcConfigurer
{
@Autowired
private lateinit var amazonSNS: AmazonSNS
override fun addArgumentResolvers(argumentResolvers: MutableList<HandlerMethodArgumentResolver>) {
argumentResolvers.add(NotificationHandlerMethodArgumentResolverConfigurationUtils.getNotificationHandlerMethodArgumentResolver(amazonSNS))
}
}