欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SpringBoot部署在Weblogic的操作步驟

 更新時間:2021年07月30日 08:58:57   作者:笑小楓  
這篇文章主要介紹了SpringBoot部署在Weblogic的操作步驟,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

SpringBoot版本:2.0.1.RELEASE

WebLogic版本:Weblogic 12c

本文為測試SpringBoot項目部署在Weblogic服務(wù)器上的測試項目。不牽扯到任何的業(yè)務(wù)邏輯。可以直接將本文重點(diǎn)標(biāo)注的幾個點(diǎn)移至您現(xiàn)有的項目。

SpringBoot項目的pom.xml文件

其中需要添加的依賴為:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-legacy</artifactId>
    <version>2.0.0.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>

打成war包文件:<packaging>war</packaging>

完整文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Springboot project run on weblogic.</description>
    <packaging>war</packaging>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- 部署weblogic需要 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-legacy</artifactId>
            <version>2.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

添加web.xml和weblogic.xml文件

在main目錄下創(chuàng)建webapp目錄,和java、resources同級。

在webapp目錄下添加WEB-INF目錄,在WEB-INF目錄下創(chuàng)建web.xml和weblogic.xml文件。

web.xml和weblogic.xml文件內(nèi)容如下:

web.xml,其中com.example.demo.DemoApplication為你項目的啟動類文件的目錄。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>com.example.demo.DemoApplication</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener</listener-class>
    </listener>

    <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>

weblogic.xml,其中<context-root>/demo</context-root>為項目啟動后的訪問路徑。如果不需要,直接改為<context-root>/</context-root>即可

<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app xmlns="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.3/weblogic-web-app.xsd">

    <container-descriptor>
        <prefer-application-packages>
            <package-name>org.slf4j</package-name>
            <package-name>javax.validation.*</package-name>
            <package-name>org.hibernate.*</package-name>
            <package-name>javax.el.*</package-name>
            <package-name>org.springframework.*</package-name>
        </prefer-application-packages>
    </container-descriptor>
    <context-root>/demo</context-root>
</weblogic-web-app>

項目啟動類:DemoApplication.java

注意將啟動類繼承SpringBootServletInitializer, 實(shí)現(xiàn)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";
    }
}

以上項目配置完成,執(zhí)行mvn clean package打成war文件。可以直接使用idea的maven打包。

部署項目到weblogic

詳細(xì)步驟如下圖:

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述 在這里插入圖片描述

在這里插入圖片描述

顯示部署成功后,在瀏覽器輸入地址訪問:http://192.168.2.10:7001/demo/test

系統(tǒng)測試

顯示結(jié)果如下圖:

在這里插入圖片描述

程序源碼

本文涉及到的項目源碼已經(jīng)push到github上,需要的小伙伴可以去拿一下。

如果項目一直部署不成功,建議小伙伴創(chuàng)建一個新的空項目,然后只放必須的pom依賴,放入weblogic的配置,打包試一下是否成功。

若使用本文的配置,建議使用全套呦,可能因為很小的細(xì)節(jié)不一致,就會導(dǎo)致項目部署出錯。

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • SpringBoot請求參數(shù)加密、響應(yīng)參數(shù)解密的實(shí)現(xiàn)

    SpringBoot請求參數(shù)加密、響應(yīng)參數(shù)解密的實(shí)現(xiàn)

    在項目開發(fā)工程中,有的項目可能對參數(shù)安全要求比較高,在整個http數(shù)據(jù)傳輸?shù)倪^程中都需要對請求參數(shù)、響應(yīng)參數(shù)進(jìn)行加密,本文主要介紹了SpringBoot請求參數(shù)加密、響應(yīng)參數(shù)解密的實(shí)現(xiàn),感興趣的可以了解一下
    2024-01-01
  • Java實(shí)現(xiàn)添加條形碼到PDF表格的方法詳解

    Java實(shí)現(xiàn)添加條形碼到PDF表格的方法詳解

    條碼的應(yīng)用已深入生活和工作的方方面面。本文以操作PDF文件為例,介紹如何利用Java語言在編輯表格時,向單元格中添加條形碼,感興趣的可以學(xué)習(xí)一下
    2022-06-06
  • Java并發(fā)編程之線程間的通信

    Java并發(fā)編程之線程間的通信

    當(dāng)線程在系統(tǒng)內(nèi)運(yùn)行時,程序通常無法準(zhǔn)確的控制線程的輪換執(zhí)行,但我們可以通過一些機(jī)制來保障線程的協(xié)調(diào)運(yùn)行,本文著重講解線程間的通信機(jī)制
    2021-06-06
  • Java設(shè)計模式之觀察者模式_動力節(jié)點(diǎn)Java學(xué)院整理

    Java設(shè)計模式之觀察者模式_動力節(jié)點(diǎn)Java學(xué)院整理

    這篇文章給大家介紹流量java設(shè)計模式之觀察者模式,定義對象間一種一對多的依賴關(guān)系,使得當(dāng)每一個對象改變狀態(tài)。下面通過類圖和實(shí)例代碼給大家介紹java設(shè)計模式之觀察者模式,感興趣的朋友一起看看吧
    2017-08-08
  • MyBatis3傳遞多個參數(shù)(Multiple Parameters)

    MyBatis3傳遞多個參數(shù)(Multiple Parameters)

    這篇文章主要介紹了MyBatis3傳遞多個參數(shù),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • 從0構(gòu)建Oauth2Server服務(wù)之Refreshing-access-tokens

    從0構(gòu)建Oauth2Server服務(wù)之Refreshing-access-tokens

    這篇文章主要為大家介紹了從0構(gòu)建Oauth2Server服務(wù)之Refreshing-access-tokens刷新令牌示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-05-05
  • SpringBoot項目導(dǎo)入aliyun oss starter依賴后啟動報錯問題

    SpringBoot項目導(dǎo)入aliyun oss starter依賴后啟動報錯問題

    這篇文章主要介紹了SpringBoot項目導(dǎo)入aliyun oss starter依賴后啟動報錯問題及解決方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • Java詳細(xì)講解堆排序與時間復(fù)雜度的概念

    Java詳細(xì)講解堆排序與時間復(fù)雜度的概念

    本文主要介紹了java實(shí)現(xiàn)堆排序以及時間復(fù)雜度,堆排序這種排序算法是我們經(jīng)常用到的,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • RabbitMQ的ACK確認(rèn)機(jī)制保障消費(fèi)端消息的可靠性詳解

    RabbitMQ的ACK確認(rèn)機(jī)制保障消費(fèi)端消息的可靠性詳解

    這篇文章主要介紹了RabbitMQ的ACK確認(rèn)機(jī)制保障消費(fèi)端消息的可靠性詳解,簡單來說,就是你必須關(guān)閉 RabbitMQ 的自動ack ,可以通過一個 api 來調(diào)用就行,然后每次你自己代碼里確保處理完的時候,再在程序里 ack 一把,需要的朋友可以參考下
    2023-12-12
  • hashset去除重復(fù)值原理實(shí)例解析

    hashset去除重復(fù)值原理實(shí)例解析

    這篇文章主要介紹了hashset去除重復(fù)值原理實(shí)例解析,具有一定借鑒價值,需要的朋友可以參考下。
    2017-12-12

最新評論