iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >解决weblogic部署springboot项目步骤及可能会出现的问题
  • 162
分享到

解决weblogic部署springboot项目步骤及可能会出现的问题

2024-04-02 19:04:59 162人浏览 安东尼

Python 官方文档:入门教程 => 点击学习

摘要

项目为SpringBoot的需要适配WEBlogic 第一步 修改启动类, 很多搜到的都是这样 修改启动类StartEPassApplication 第二步 完全排除掉Tomcat

项目SpringBoot的需要适配WEBlogic

第一步

修改启动类, 很多搜到的都是这样

修改启动类StartEPassApplication

在这里插入图片描述

第二步

完全排除掉Tomcat

详情请看下面的地址

完全排除springboot的tomcat还需加上weblogic.xml


<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="Http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
        http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:container-descriptor>
    <wls:prefer-application-packages>
        <wls:package-name>org.slf4j</wls:package-name>
        <wls:package-name>org.springframework.*</wls:package-name>
    </wls:prefer-application-packages>
</wls:container-descriptor>
<wls:context-root>/xxx</wls:context-root>
</wls:weblogic-web-app>

到这里修改基本完成,但是本人在部署时还需到两个棘手的问题:

@swagger2注解与weblogic的兼容问题没有解决

描述:开启@swagger2注解,项目安装失败。

在这里插入图片描述

有知道的老哥麻烦留言一下,这里还未解决

项目上传文件失败,同样代码在tomcat中能完美运行

在weblogic中相同的东西传递过来就是null,导致功能失效。到处找方案,看到可能是因为编码问题或者资源路径问题导致。不断尝试找到办法。

-解决办法:完善weblogic.xml完美解决


<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
        http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:container-descriptor>
    <wls:prefer-application-packages>
        <wls:package-name>org.slf4j</wls:package-name>
        <wls:package-name>org.springframework.*</wls:package-name>
    </wls:prefer-application-packages>
</wls:container-descriptor>
    <wls:charset-params>
        <wls:input-charset>
            <wls:resource-path>/*</wls:resource-path>
            <wls:java-charset-name>UTF-8</wls:java-charset-name>
        </wls:input-charset>
    </wls:charset-params>
<wls:context-root>/xxx</wls:context-root>
</wls:weblogic-web-app>

SpringBoot项目部署在weblogic中间件注意事项

1、SpringBoot项目Tomcat部署无需手动配置web.xml

但是使用weblogic部署项目时需配置所有相关的监听器和过滤器等。


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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">
 
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>com.cebbank.CebbankLoansMeetingApplication</param-value>
	</context-param>
 
	<listener>
		<listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener</listener-class>
	</listener>
 
	<listener>
		<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
	</listener>
 
	<filter>
		<filter-name>characterEncoding</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>characterEncoding</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	
	<!-- <filter>
		<filter-name>metricFilter</filter-name>
		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>metricFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping> -->
 
	<servlet>
		<servlet-name>appServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextAttribute</param-name>
			<param-value>org.springframework.web.context.WebApplicationContext.ROOT</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
 
	<servlet-mapping>
		<servlet-name>appServlet</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
 
</web-app>

2、只配置web.xml配置文件

部署在weblogic上会失败,需另外配置一个weblogic.xml文件(跟web.xml在同一目录)


<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
    xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
    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/ejb-jar_3_0.xsd
        http://xmlns.oracle.com/weblogic/weblogic-web-app
        http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
    <wls:container-descriptor>
        <wls:prefer-application-packages>   
            <wls:package-name>org.slf4j</wls:package-name>
        </wls:prefer-application-packages>
    </wls:container-descriptor>
     <wls:context-root>/</wls:context-root>
     <wls:virtual-directory-mapping>
     		<wls:local-path>d:/</wls:local-path>
     	 	<wls:url-pattern>/recordings/*</wls:url-pattern>
     </wls:virtual-directory-mapping>
</wls:weblogic-web-app> 

注意:<wls:virtual-directory-mapping>为虚拟目录相关配置,可用来保存上传的资源,可作为静态资源直接访问

以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。

--结束END--

本文标题: 解决weblogic部署springboot项目步骤及可能会出现的问题

本文链接: https://www.lsjlt.com/news/131463.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作