java包部署到weblogic_SpringBoot部署在Weblogic步骤详情

本文详述了SpringBoot 2.0.1.RELEASE项目如何部署到Weblogic 12c,包括修改pom.xml添加依赖,创建web.xml和weblogic.xml,设置启动类,并最终打包成war文件进行部署。成功部署后,通过http://192.168.2.10:7001/demo/test可访问测试。
摘要由CSDN通过智能技术生成

SpringBoot版本:2.0.1.RELEASE

WebLogic版本:Weblogic 12c

本文为测试SpringBoot项目部署在Weblogic服务器上的测试项目。不牵扯到任何的业务逻辑。可以直接将本文重点标注的几个点移至您现有的项目。

SpringBoot项目的pom.xml文件

其中需要添加的依赖为:

org.springframework.boot

spring-boot-legacy

2.0.0.RELEASE

org.springframework.boot

spring-boot-starter-tomcat

provided

打成war包文件:war

完整文件如下:

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

org.springframework.boot

spring-boot-starter-parent

2.0.1.RELEASE

com.example

demo

0.0.1-SNAPSHOT

demo

Springboot project run on weblogic.

war

1.8

org.springframework.boot

spring-boot-starter

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-legacy

2.0.0.RELEASE

org.springframework.boot

spring-boot-starter-tomcat

provided

org.springframework.boot

spring-boot-maven-plugin

添加web.xml和weblogic.xml文件

在main目录下创建webapp目录,和java、resources同级。

在webapp目录下添加WEB-INF目录,在WEB-INF目录下创建web.xml和weblogic.xml文件。

web.xml和weblogic.xml文件内容如下:

web.xml,其中com.example.demo.DemoApplication为你项目的启动类文件的目录。

contextConfigLocation

com.example.demo.DemoApplication

org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener

appServlet

org.springframework.web.servlet.DispatcherServlet

contextAttribute

org.springframework.web.context.WebApplicationContext.ROOT

1

appServlet

/

weblogic.xml,其中/demo为项目启动后的访问路径。如果不需要,直接改为/即可

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.3/weblogic-web-app.xsd">

org.slf4j

javax.validation.*

org.hibernate.*

javax.el.*

org.springframework.*

/demo

项目启动类:DemoApplication.java

注意将启动类继承SpringBootServletInitializer, 实现WebApplicationInitializer

package com.example.demo;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.builder.SpringApplicationBuilder;

import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

import org.springframework.web.WebApplicationInitializer;

import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RestController;

@RestController

@SpringBootApplication

public class DemoApplication extends SpringBootServletInitializer implements WebApplicationInitializer {

@Override

protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

return application.sources(DemoApplication.class);

}

public static void main(String[] args) {

SpringApplication.run(DemoApplication.class, args);

}

@GetMapping("/test")

public String test(){

return "test";

}

}

以上项目配置完成,执行mvn clean package打成war文件。可以直接使用idea的maven打包。

部署项目到weblogic

详细步骤如下图:

519ef597d1488864e951b296d0997afc.png

280ee343ad5edf3eca597b95119610df.png

6e259da9ffcfcb71e80f65b6b8773ef6.png

d3a99366ff893412fc6acc34d3b6ece9.png

864ec4cb245f4b72e028bee8b3b2fab6.png

04e37cee3c32dc018c93664615b27b9e.png

显示部署成功后,在浏览器输入地址访问:http://192.168.2.10:7001/demo/test

系统测试

显示结果如下图:

cfe3339520171f228b110db6acf01227.png

本文到此结束了,后续文章会陆续更新,文档会同步在CSDN和GitHub保持同步更新。

点个关注再走呗~~~

本文地址:https://blog.csdn.net/qq_34988304/article/details/107083786

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值