对于想了解在SpringIntegration中为Redis创建MessageSource的读者,本文将提供新的信息,我们将详细介绍spring中使用redis,并且为您提供关于c#–关于resour
对于想了解在Spring Integration中为Redis创建MessageSource的读者,本文将提供新的信息,我们将详细介绍spring中使用redis,并且为您提供关于c# – 关于resources.ApplyResources的System.Resources.MissingManifestResourceException、Caused by: java.io.FileNotFoundException: class path resource [../../resources/config/spring.xml]...、How to resolve warning message Access restriction -The type Resource is not accessible、java – 在Spring MVC框架中不使用MessageSourceAware访问MessageSource的方法的有价值信息。
本文目录一览:- 在Spring Integration中为Redis创建MessageSource(spring中使用redis)
- c# – 关于resources.ApplyResources的System.Resources.MissingManifestResourceException
- Caused by: java.io.FileNotFoundException: class path resource [../../resources/config/spring.xml]...
- How to resolve warning message Access restriction -The type Resource is not accessible
- java – 在Spring MVC框架中不使用MessageSourceAware访问MessageSource的方法
在Spring Integration中为Redis创建MessageSource(spring中使用redis)
我想配置InboundChannelAdapter,以便它应该从Redis队列中弹出消息,并将其传递给基于Java的注释中的ServiceActivator(仅,避免使用XML)。我从Spring文档中找到了代码:
@Bean("someAdapter.source")@EndpointId("someAdapter")@InboundChannelAdapter(channel = "channel3", poller = @Poller(fixedDelay = "5000"))public MessageSource<?> source() { return () -> { ... };}
但是我不明白的是,如何通过使用redisConnectionFactory从redis队列中弹出数据来返回MessageSource?
换句话说,如何在基于Java的注释中做到这一点?
<int-redis:queue-inbound-channel-adapter id="postPublicationInboundAdapter" connection-factory="redisConnectionFactory" channel="postPublicationChannel" error-channel="postPublicationLoggingChannel" receive-timeout="5000" queue="archive.post.publication.queue" serializer="postPublicationJsonRedisSerializer"/>
答案1
小编典典- 让我们从这里开始:[https](https://docs.spring.io/spring-
- integration/docs/5.0.9.RELEASE/reference/html/overview.html#programming-tips)
- //docs.spring.io/spring-
integration/docs/5.0.9.RELEASE/reference/html/overview.html#programming-
tips
借助XML配置和Spring
Integration命名空间的支持,XML解析器隐藏了如何声明目标bean并将它们连接在一起。对于Java和注释配置,了解用于目标最终用户应用程序的Framework
API非常重要。
然后我们为此打开一个XSD <int-redis:queue-inbound-channel-adapter>
:
<xsd:element name="queue-inbound-channel-adapter"> <xsd:annotation> <xsd:documentation> Defines a Message Producing Endpoint for the ''org.springframework.integration.redis.inbound.RedisQueueMessageDrivenEndpoint'' for listening a Redis queue. </xsd:documentation> </xsd:annotation>
因此,听起来a int-redis:queue-inbound-channel-adapter
不是MessageSource
。因此@InboundChannelAdapter
是死胡同。我同意XML元素的名称当时是错误的,但是重命名它为时已晚。
从这里我们也已经弄清楚我们需要处理这个问题RedisQueueMessageDrivenEndpoint
。并且由于它是 消息驱动的
,自我管理的,因此我们不需要任何特殊的注释。足以将其声明为如下所示的bean:
@BeanRedisQueueMessageDrivenEndpoint redisQueueMessageDrivenEndpoint(RedisConnectionFactory redisConnectionFactory, RedisSerializer<?> serializer) { RedisQueueMessageDrivenEndpoint endpoint = new RedisQueueMessageDrivenEndpoint("archive.post.publication.queue", redisConnectionFactory); endpoint.setOutputChannelName("postPublicationChannel"); endpoint.setErrorChannelName("postPublicationLoggingChannel"); endpoint.setReceiveTimeout(5000); endpoint.setSerializer(serializer); return endpoint;}
c# – 关于resources.ApplyResources的System.Resources.MissingManifestResourceException
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditorPane)); this.editorControl = new EditorControl(); resources.ApplyResources(this.editorControl,"editorControl",CultureInfo.CurrentUICulture);
当代码执行时,它抛出一个’System.Resources.MissingManifestResourceException’,所有错误消息都只是吼叫.
An exception of type ‘System.Resources.MissingManifestResourceException’ occurred in mscorlib.dll but was not handled in user code
Additional information: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure “Editor.EditorPane.resources” was correctly embedded or linked into assembly “Editor” at compile time,or that all the satellite assemblies required are loadable and fully signed.
解决方法
这是我在项目文件中找到的:
<EmbeddedResource Include="Main.resx" />
这就是它必须:
<EmbeddedResource Include="Main.resx"> <DependentUpon>Main.pas</DependentUpon> </EmbeddedResource>
如果没有列出这种依赖关系(我必须强调,我没有自己删除它 – 它是在某个阶段由MS Visual Studio完成的),必要的资源文件没有在编译例程中正确包含.
我希望这会有所帮助(并让其他人头疼)!
Caused by: java.io.FileNotFoundException: class path resource [../../resources/config/spring.xml]...
在尝试使用Spring的Test的时候遇到了这个错误
原来的代码:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"../../../resources/config/spring.xml"})
public class TestFund {
@Autowired
private FundService fundService;
@Test
public void testFundSelectAll() {
//System.out.println("所有基金: " + fundService.selectAll());
System.out.println(fundService);
}
}
原因分析:
修改spring的配置文件spring.xml的位置
解决方法:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:config/spring.xml")
public class TestFund {
@Autowired
private FundService fundService;
@Test
public void testFundSelectAll() {
//System.out.println("所有基金: " + fundService.selectAll());
System.out.println(fundService);
}
}
问题解决!
How to resolve warning message Access restriction -The type Resource is not accessible
Created by Wang, Jerry, last modified on Jul 08, 2016
本文同步分享在 博客“汪子熙”(CSDN)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。
java – 在Spring MVC框架中不使用MessageSourceAware访问MessageSource的方法
我有几个servlet旨在保存自己的消息源,但是有一个静态函数使用此消息源作为备份,并且在正常情况下使用全局BDB来检索本地化文本.
我想知道是否有一种方法可以检索调用此全局静态函数的servlet上下文的MessageSource?
我不能在所有servlet中使用MessageSourceAware.我查看了Spring文档,发现了MessageSourceAware和@autowired属性.我不能使用注释,因为我使用的是Spring 2.0.
任何帮助赞赏.
谢谢,
PARTH
WebApplicationContext webAppContext = RequestContextUtils.getWebApplicationContext(request);
MessageSource messageSource = webAppContext.getBean("messageSource");
关于在Spring Integration中为Redis创建MessageSource和spring中使用redis的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于c# – 关于resources.ApplyResources的System.Resources.MissingManifestResourceException、Caused by: java.io.FileNotFoundException: class path resource [../../resources/config/spring.xml]...、How to resolve warning message Access restriction -The type Resource is not accessible、java – 在Spring MVC框架中不使用MessageSourceAware访问MessageSource的方法的相关知识,请在本站寻找。
本文标签: