最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringBoot集成SAP的過程及本地IDEA啟動和Windows服務(wù)器部署

 更新時間:2025年07月17日 15:01:41   作者:乘風(fēng)!  
本文給大家介紹SpringBoot集成SAP的過程及本地IDEA啟動和Windows服務(wù)器部署的相關(guān)知識,本文給大家介紹的詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧

網(wǎng)上有關(guān)Springboot集成SAP有各種各樣的說法,我這里提供一個我調(diào)通的方案。如下pom配置,sapjco3.dll 放在"%JAVA_HOME%\bin\",否則報nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.sap.conn.jco.JCo,服務(wù)器部署時也是這樣放置,

sapjco3.dll和sapjco3.jar放在resources\lib下

<?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>com.demo</groupId>
        <artifactId>OPM</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.demo</groupId>
    <artifactId>open-manager</artifactId>
    <packaging>jar</packaging>
    <name>open-manager</name>
    <description>open-manager</description>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.demo</groupId>
            <artifactId>common</artifactId>
            <!--不加版本無法引用-->
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.sapjco3</groupId>
            <artifactId>sapjco</artifactId>
            <version>3.0</version>
            <scope>system</scope>
            <systemPath>${pom.basedir}/src/main/resources/lib/sapjco3.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    </dependencies>
    <profiles>
        <!-- 本地環(huán)境 -->
        <profile>
            <id>local</id>
            <properties>
                <spring.profiles.active>local</spring.profiles.active>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <!-- 開發(fā)環(huán)境 -->
        <profile>
            <id>dev</id>
            <properties>
                <spring.profiles.active>dev</spring.profiles.active>
            </properties>
        </profile>
        <!-- 生產(chǎn)環(huán)境 -->
        <profile>
            <id>prod</id>
            <properties>
                <spring.profiles.active>prod</spring.profiles.active>
            </properties>
        </profile>
    </profiles>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!--為false,取消本地的system的jar打入-->
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.3.0</version>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/webapp</directory>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <!-- true表示利用占位符進(jìn)行替換 -->
                <filtering>true</filtering>
                <includes>
                    <!--Maven 資源過濾是為文本文件設(shè)計(jì)的(如屬性文件、XML 等)-->
                    <include>**/*.properties</include>
                    <include>application.yml</include>
                    <!-- ${spring.profiles.active}就是我們指定的環(huán)境,會被替換掉 -->
                    <include>application-${spring.profiles.active}.yml</include>
                    <include>**/*.xml</include>
                    <include>**/*.html</include>
                    <include>**/*.json</include>
                    <include>webapp/</include>
                </includes>
                <excludes>
                    <!-- 排除目錄 -->
                    <exclude>lib/**</exclude>
                    <exclude>**/*.jar</exclude>
                    <exclude>**/*.dll</exclude> <!--sapjco3.dll "%JAVA_HOME%\bin\"-->
                    <exclude>**/*.jks</exclude>
                    <exclude>**/*.png</exclude>
                </excludes>
            </resource>
            <!-- 新增:單獨(dú)處理二進(jìn)制文件(不進(jìn)行過濾) -->
            <resource>
                <directory>src/main/resources/lib</directory>
                <filtering>false</filtering>
                <targetPath>BOOT-INF/lib</targetPath>  <!-- 關(guān)鍵修改 -->
                <includes>
                    <include>sapjco3.jar</include>
                </includes>
            </resource>
            <!-- 處理其他資源 -->
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <targetPath>BOOT-INF/classes</targetPath>
                <excludes>
                    <exclude>lib/**</exclude> <!-- 排除已單獨(dú)處理的 lib 目錄 -->
                </excludes>
                <includes>
                    <include>**/*.jks</include>
                    <include>**/*.png</include>
                </includes>
            </resource>
        </resources>
    </build>
</project>
package com.demo.openmanager.sap;
import com.demo.common.util.StringUtils;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.ext.DestinationDataProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
@Slf4j
public class XpJco {
    @Value("${sap.host}")
    private String SAP_HOST;
    @Value("${sap.client}")
    private String SAP_CLIENT;
    @Value("${sap.sysno}")
    private String SAP_SYS_NO;
    @Value("${sap.user}")
    private String SAP_USER;
    @Value("${sap.pass}")
    private String SAP_PASS;
    @Value("${sap.lang}")
    private String SAP_LANG;
    @Value("${sap.poolCapacity}")
    private String SAP_POOL_CAPACITY;
    @Value("${sap.peakLimit}")
    private String SAP_PEAK_LIMIT;
    @Value("${sap.jcoSaprouter}")
    private String SAP_JCO_SAPROUTER;
    public synchronized JCoDestination getJCoDestination(String filename) {
        JCoDestination destination = null;
        try {
            destination = JCoDestinationManager.getDestination(filename);
        } catch (JCoException e) {
            e.printStackTrace();
        }
        return destination;
    }
    private static boolean creatSapPros(String filename, String host, String sysno, String client, String user, String pass,
                                        String lang, String pool_capacity, String peak_limit, String JCO_SAPROUTER) {
        Properties pros = new Properties();
        boolean iscreate = false;
        pros.clear(); // 先清空
        pros.setProperty(DestinationDataProvider.JCO_ASHOST, host);
        pros.setProperty(DestinationDataProvider.JCO_SYSNR, sysno);
        pros.setProperty(DestinationDataProvider.JCO_CLIENT, client);
        pros.setProperty(DestinationDataProvider.JCO_USER, user);
        pros.setProperty(DestinationDataProvider.JCO_PASSWD, pass);
        pros.setProperty(DestinationDataProvider.JCO_LANG, lang);
        pros.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, pool_capacity);
        pros.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, peak_limit);
        if (StringUtils.isNoneBlank(JCO_SAPROUTER)) {
            pros.setProperty(DestinationDataProvider.JCO_SAPROUTER, JCO_SAPROUTER);
        }
        iscreate = createFiles(filename, pros);
        if (iscreate) {
            return true;
        } else {
            return false;
        }
    }
    /**
     * @param filename
     * @return
     */
    private static boolean isFileExist(String filename) {
        File file = new File(filename + ".jcoDestination");
        log.info("JCO path:" + file.getPath());
        log.info("JCO AbsolutePath:" + file.getAbsolutePath());
        // 最后會放在Q:\IdeaWork\OPM\tz02_ywk_jco.jcoDestination
        // 環(huán)境上是放在啟動jar包所在同級目錄
        return file.exists();
    }
    /**
     * @param filename
     * @param pros
     * @return
     */
    private static boolean createFiles(String filename, Properties pros) {
        File file = new File(filename + ".jcoDestination");
        FileOutputStream fos = null;
        if (!file.exists()) {
            try {
                log.info("********* 正在寫入文件 **********");
                fos = new FileOutputStream(file, false);
                pros.store(fos, "Author: ljb");
                fos.close();
                return true;
            } catch (FileNotFoundException e) {
                log.info("-------- 找不到文件! ---------");
                e.printStackTrace();
                return false;
            } catch (IOException e) {
                log.info("-------- 內(nèi)容寫入失??! ---------");
                e.printStackTrace();
                return false;
            } finally {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        } else {
            return false;
        }
    }
    public synchronized JCoDestination getJCoDestination() {
        boolean isexist = false; // 判斷文件是否存在
        boolean isCreate = false; // 創(chuàng)建pro文件
        JCoDestination destination;
        String filename = "tz02_ywk_jco";
        isexist = XpJco.isFileExist(filename);
        log.info("-- 獲取JCoDestination isexist==" + isexist);
        if (isexist == true) {
            try {
                destination = JCoDestinationManager.getDestination(filename);
                return destination;
            } catch (JCoException e) {
                log.info("-- 獲取JCoDestination失敗! --");
                e.printStackTrace();
                return null;
            }
        } else {
            isCreate = XpJco.creatSapPros(filename, SAP_HOST, SAP_SYS_NO, SAP_CLIENT, SAP_USER, SAP_PASS, SAP_PASS,
                    SAP_POOL_CAPACITY, SAP_PEAK_LIMIT, SAP_JCO_SAPROUTER);
            if (isCreate == true) {
                try {
                    destination = JCoDestinationManager.getDestination(filename);
                    log.info("獲取JCoDestination!成功");
                    return destination;
                } catch (JCoException e) {
                    log.info("無法獲取JCoDestination!");
                    e.printStackTrace();
                    return null;
                }
            } else { // 如果文件不存在
                return null;
            }
        }
    }
}

到此這篇關(guān)于SpringBoot集成SAP,本地IDEA啟動和Windows服務(wù)器部署的文章就介紹到這了,更多相關(guān)SpringBoot集成SAP內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Spring Data Jpa的四種查詢方式詳解

    Spring Data Jpa的四種查詢方式詳解

    這篇文章主要介紹了Spring Data Jpa的四種查詢方式詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2019-12-12
  • 使用Java程序模擬實(shí)現(xiàn)新冠病毒傳染效果

    使用Java程序模擬實(shí)現(xiàn)新冠病毒傳染效果

    這篇文章主要介紹了用Java程序模擬實(shí)現(xiàn)新冠病毒傳染效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-08-08
  • Java數(shù)據(jù)結(jié)構(gòu)之?dāng)?shù)組(動力節(jié)點(diǎn)之Java學(xué)院整理)

    Java數(shù)據(jù)結(jié)構(gòu)之?dāng)?shù)組(動力節(jié)點(diǎn)之Java學(xué)院整理)

    這篇文章主要介紹了Java數(shù)據(jù)結(jié)構(gòu)之?dāng)?shù)組(動力節(jié)點(diǎn)之Java學(xué)院整理)的相關(guān)資料,包括創(chuàng)建和內(nèi)存分配,數(shù)組封裝后的使用等,需要的朋友參考下吧
    2017-04-04
  • 使用Java繪制一個520愛心圖案的示例代碼

    使用Java繪制一個520愛心圖案的示例代碼

    520在中國網(wǎng)絡(luò)文化中代表"我愛你",用代碼繪制一個愛心圖案是一種浪漫的表達(dá)方式,這篇文章小編就來和大家介紹一下如何使用Java繪制一個520愛心圖案吧
    2025-05-05
  • MyBatis-Plus多表聯(lián)查的實(shí)現(xiàn)方法(動態(tài)查詢和靜態(tài)查詢)

    MyBatis-Plus多表聯(lián)查的實(shí)現(xiàn)方法(動態(tài)查詢和靜態(tài)查詢)

    本文用示例介紹使用MyBatis-Plus進(jìn)行多表查詢的方法,包括靜態(tài)查詢和動態(tài)查詢,通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧
    2022-03-03
  • Java實(shí)現(xiàn)集合和Excel文件相互轉(zhuǎn)換

    Java實(shí)現(xiàn)集合和Excel文件相互轉(zhuǎn)換

    本文主要介紹了使用Java和ApachePOI庫將集合轉(zhuǎn)化為包含合并單元格的Excel文件,及從Excel文件流中讀取并轉(zhuǎn)化為集合,具有一定的參考價值,感興趣的可以了解一下
    2025-08-08
  • Java源碼解析之ConcurrentHashMap

    Java源碼解析之ConcurrentHashMap

    今天帶大家分析Java源碼,文中對Java ConcurrentHashMap介紹的非常詳細(xì),有代碼示例,對正在學(xué)習(xí)Java的小伙伴們有很好的幫助,需要的朋友可以參考下
    2021-05-05
  • 深入理解spring如何管理事務(wù)

    深入理解spring如何管理事務(wù)

    文章詳細(xì)介紹了Spring框架中的事務(wù)管理機(jī)制,包括事務(wù)的基本概念、事務(wù)管理的兩種方式、Spring事務(wù)管理的整體架構(gòu)、事務(wù)配置、聲明式事務(wù)的實(shí)現(xiàn)原理、事務(wù)的關(guān)鍵流程、事務(wù)屬性與配置,以及實(shí)際開發(fā)中常見的事務(wù)問題和解決方案,感興趣的朋友一起看看吧
    2025-01-01
  • 基于Rest的API解決方案(jersey與swagger集成)

    基于Rest的API解決方案(jersey與swagger集成)

    下面小編就為大家?guī)硪黄赗est的API解決方案(jersey與swagger集成)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-08-08
  • java 和 json 對象間轉(zhuǎn)換

    java 和 json 對象間轉(zhuǎn)換

    這篇文章主要介紹了java 和 json 對象間轉(zhuǎn)換,需要的朋友可以參考下
    2014-03-03

最新評論

晋江市| 彩票| 通化县| 左贡县| 体育| 台东市| 定兴县| 嘉兴市| 伊宁县| 沐川县| 舟山市| 冕宁县| 崇礼县| 渭南市| 乌审旗| 抚松县| 南乐县| 涞源县| 赣州市| 大渡口区| 三亚市| 平江县| 佛山市| 怀宁县| 浙江省| 金山区| 九江市| 平度市| 建湖县| 青神县| 远安县| 施甸县| 犍为县| 栾川县| 金阳县| 宁德市| 宣武区| 昌宁县| 菏泽市| 蓝田县| 仁怀市|