springboot应用部署到weblogic 基本步骤 您所在的位置:网站首页 springboot项目部署在tomcat springboot应用部署到weblogic 基本步骤

springboot应用部署到weblogic 基本步骤

2023-08-14 18:07| 来源: 网络整理| 查看: 265

springboot应用部署到weblogic 基本步骤 1、在原pom.xml的基础上增添leagcy依赖,并修改打包方式为war2、去掉spring boot依赖自带的tomcat,使用外置tomcat,若有servlet-api的使用,则一起加入依赖3、修改Springboot启动类 增加extends SpringBootServletInitializer implements WebApplicationInitializer4、使用IDEA增加web.xml和weblogic.xml文件5、 增加打包插件到pom.xml6、构建war包7、通过weblogic控制台部署war包,完成后通过127.0.0.1:7001打开应用首页,成功打开即完成部署8、注意点

1、在原pom.xml的基础上增添leagcy依赖,并修改打包方式为war liqi-admin war org.springframework.boot spring-boot-legacy 2.0.0.RELEASE 2、去掉spring boot依赖自带的tomcat,使用外置tomcat,若有servlet-api的使用,则一起加入依赖 org.springframework.boot spring-boot-starter-tomcat provided org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-tomcat tomcat-embed-el org.apache.tomcat.embed javax.servlet servlet-api 2.5 javax.servlet javax.servlet-api 3.1.0 org.apache.tomcat tomcat-servlet-api 8.5.23 3、修改Springboot启动类 增加extends SpringBootServletInitializer implements WebApplicationInitializer @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) @ComponentScan(basePackages = "com.liqi") public class LiQiApplication extends SpringBootServletInitializer implements WebApplicationInitializer { public static void main(String[] args) { SpringApplication.run(LiQiApplication.class, args); System.out.println("(♥◠‿◠)ノ゙ LIQI程序启动成功! ლ(´ڡ`ლ)゙ \n"); } }

启动类同级package增加一个配置类 在这里插入图片描述

public class SpringBootStartApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){ return builder.sources(LiQiApplication.class); } } 4、使用IDEA增加web.xml和weblogic.xml文件

选中模块按F4,如图分别点击“+”和 add application server spcific descriptor增添web.xml和weblogic.xml 在这里插入图片描述 weblogic.xml内容如下:

12.1.3 / org.springframework.* org.hibernate.* javax.validation.* javax.validation.spi.* org.slf4j.* true

使用package-name标签指定特定的包优先使用应用自带jar,而不是weblogic的lib库

web.xml文件内容如下:

contextConfigLocation com.liqi.admin.LiQiApplication org.springframework.web.context.ContextLoaderListener metricFilter org.springframework.web.filter.DelegatingFilterProxy metricFilter /* shiroFilter org.springframework.web.filter.DelegatingFilterProxy targetFilterLifecycle true shiroFilter /* REQUEST FORWARD INCLUDE ERROR appServlet org.springframework.web.servlet.DispatcherServlet contextAttribute org.springframework.web.context.WebApplicationContext.ROOT 1 appServlet / 5、 增加打包插件到pom.xml org.apache.maven.plugins maven-war-plugin true ${project.version} true lib/ ${project.artifactId} org.springframework.boot spring-boot-maven-plugin BOOT repackage 6、构建war包

在这里插入图片描述 在这里插入图片描述

7、通过weblogic控制台部署war包,完成后通过127.0.0.1:7001打开应用首页,成功打开即完成部署

在这里插入图片描述

8、注意点

(1)以上配置仅是对于我所部署项目的设置,你需要根据自己项目的实际情况酌情修改,如web.xml,标准是如文章所写,但我这么写会报错 weblogic Cannot initialize context because there is already a root application context present,后面把所有内容注释就可以正常运行了。 (2) weblogic一般package-name标签仅需要包含 " wls:package-nameorg.slf4j." "wls:package-nameorg.springframework." 其他需要的包也根据项目需要增添,如 wls:package-nameorg.hibernate.*等。

参考链接:如何优雅的在weblogic上部署spring-boot 记一次将spring-boot应用发布到weblogic的步骤以及遇到的问题 weblogic部署springboot项目war包 springboot2里运行weblogic11g



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有