Mule Api打war包 mulewar
1.追加src/main/webapp/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <context-param> <param-name>org.mule.config</param-name> <!-- example --> <!-- flow xml用逗号隔开 --> <param-value>shopcategory-error.xml,shopcategory.xml</param-value> </context-param> <listener> <listener-class>org.mule.config.builders.MuleXmlBuilderContextListener</listener-class> </listener> <servlet> <servlet-name>muleServlet</servlet-name> <servlet-class>org.mule.transport.servlet.MuleReceiverServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>muleServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app>
2.将pom.xml文件中packaging改为"<packaging>war</packaging>"
3.将inbound HTTP组件改为Servlet组件, 如下 :
<servlet:inbound-endpoint path="${inbound.path}" doc:name="Servlet"/>
如果需要的话, 可以在Global Element中追加Servlet connector,如下:
<servlet:connector name="Servlet" validateConnections="true" doc:name="Servlet"/>
4.当你需要获取到request body的时候,需要追加ServletMuleMessageFactory.java.(Ref:http://819342090.iteye.com/admin/blogs/2343167)
5.修改log4j.xml中log文件的路径
发布到tomcat,log文件的路径就改为${catalina.base}/logs/XXXX.log
发布到weblogic,log文件的路径就改为servers/myserver/logs/XXXX.log
6.发布
注意点:
HTTP组件改为Servlet组件之后的message属性有很多改变,很多inbound属性的属性名发生变化,也有些属性的属性值发生变化。
如果发布到weblogic,需要注意项目中读取resource文件的操作。因为war包在weblogic中发布的时候,是不会被解压的,所有读取文件会变为读取_wl_cls_gen.jar中的文件。所以都要按照读取jar包的方法来读取文件。如下:
//File file = new File(this.getClass().getResource("/XQueries/CategorySetsGetResponse.xq").getPath()); //InputStream in = new FileInputStream(file); ClassLoader classloader =Thread.currentThread().getContextClassLoader(); InputStream in =classloader.getResourceAsStream("/XQueries/CategorySetsGetResponse.xq");
参考文件
https://docs.mulesoft.com/mule-user-guide/v/3.4/deploying-mule-as-a-service-to-tomcat
https://docs.mulesoft.com/mule-user-guide/v/3.4/servlet-endpoint-reference
https://docs.mulesoft.com/mule-user-guide/v/3.4/servlet-transport-reference
https://docs.mulesoft.com/mule-user-guide/v/3.4/servlet-transport-reference
https://dzone.com/articles/deploying-mavenized-mule-webapp-on-tomcat
上一篇: Mate 30 Pro要用?华为探索手机一体化玻璃技术:干掉金属中框
下一篇: state