是否可以在不依赖 spring 的情况下启动嵌入的 Mule3?
我正在尝试使用从普通 java 应用程序嵌入的 Mule 3.2.1。该应用程序应该在存储空间有限的环境中运行。
我尝试了类似 (import, 为简洁起见省略异常):
DefaultMuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
ConfigurationBuilder configBuilder = new AutoConfigurationBuilder("mule-config.xml");
MuleContext muleContext = muleContextFactory.createMuleContext(configBuilder);
muleContext.start();
以及这样的方法:
AutoConfigurationBuilder configBuilder = new AutoConfigurationBuilder("mule-config.xml");
DefaultMuleConfiguration configuration = new DefaultMuleConfiguration();
MuleContextBuilder contextBuilder = new DefaultMuleContextBuilder();
contextBuilder.setMuleConfiguration(configuration);
MuleContext muleContext = new DefaultMuleContextFactory().createMuleContext(configbuilder, contextBuilder);
muleContext.start();
但两者都需要 spring-core、spring-beans、spring-context 和一些公共库。任何帮助都会很棒。
I am trying to use Mule 3.2.1 embedded from a plain java application. The application is suppose to run in an environment where storage space is limited.
I tried something like (import, exceptions omitted for brevity):
DefaultMuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
ConfigurationBuilder configBuilder = new AutoConfigurationBuilder("mule-config.xml");
MuleContext muleContext = muleContextFactory.createMuleContext(configBuilder);
muleContext.start();
and also this:
AutoConfigurationBuilder configBuilder = new AutoConfigurationBuilder("mule-config.xml");
DefaultMuleConfiguration configuration = new DefaultMuleConfiguration();
MuleContextBuilder contextBuilder = new DefaultMuleContextBuilder();
contextBuilder.setMuleConfiguration(configuration);
MuleContext muleContext = new DefaultMuleContextFactory().createMuleContext(configbuilder, contextBuilder);
muleContext.start();
but both require spring-core, spring-beans, spring-context and some commons libraries. Any help would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果使用XML配置,则需要Spring。
如果你不想使用 Spring,你的选择是:
如果您只想使用原始传输,即不配置任何流程或模式,您可以在没有 Spring 的情况下完成此操作,但请记住,如果
mule-core< /code> 依赖关系不会传递 Spring,但所有模块和传输都会传递。这意味着您必须使用过滤来阻止这些依赖项。
例如,要使用 HTTP 传输,您需要这些 Maven 依赖项:
有了这些依赖项,您就可以执行以下操作:
请注意,如果这就是您使用 Mule 所做的全部操作,那么您宁愿直接使用 Apache HTTP 客户端 :)
If you use the XML configuration, you need Spring.
If you don't want to use Spring, your options are:
If you only want to use raw transports, ie not configure any flow or pattern, you can do it without Spring but bear in mind that, if the
mule-core
dependency doesn't bring Spring transitively, all the modules and transports do. This means that you'll have to use filtering to keep these dependencies at bay.For example to use the HTTP transport, you would need these Maven dependencies:
With this in place you then do:
Note that if that's all you're doing with Mule, then you'd rather use the Apache HTTP Client directly :)