温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

springboot项目接入sap与部署到docker遇到的问题有哪些

发布时间:2021-09-29 15:56:33 来源:亿速云 阅读:284 作者:柒染 栏目:云计算

本篇文章为大家展示了springboot项目接入sap与部署到docker遇到的问题有哪些,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

前言

主要记录在协助部署接入sap遇到的问题,且只记录解决问题的答案,不说明原理。

问题实录

1、问题一:Illegal JCo archive "sapjco-1.0.jar". It is not allowed to rename or repackage the original archive "sapjco3.jar"

解决方案一:手动项目中将sapjco-1.0.jar重名为sapjco3.jar

不过我们没采用这种方案

解决方案二:指定maven的scope为system,形如下

 <dependency>
            <groupId>com.sap</groupId>
            <artifactId>sapjco</artifactId>
            <version>${sap.version}</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/sapjco3.jar</systemPath>
        </dependency>

然后指定resources,形如下

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                    <compilerArguments>
                        <extdirs>${project.basedir}/lib</extdirs>
                    </compilerArguments>
                </configuration>
            </plugin>

        </plugins>

        <resources>
            <resource>
                <directory>${project.basedir}/lib</directory>
                <targetPath>BOOT-INF/lib/</targetPath>
                <includes>
                    <include>**/*.jar</include>
                </includes>
            </resource>
            <resource>
                <directory>${project.basedir}/lib</directory>
                <targetPath>BOOT-INF</targetPath>
                <includes>
                    <include>**/*.so</include>
                    <include>**/*.dll</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <!--<targetPath>BOOT-INF/classes/</targetPath>-->
                <includes>
                    <include>**/*.yml</include>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>
    </build>

这个的作用是将sapjco3.jar打进BOOT-INF/lib/

问题二:java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path

因为项目是部署到docker里面去,因此本文只写基于docker的解决方案

解决方案如下:

在dockerFile里面指定LD_LIBRARY_PATH环境变量,形如下

FROM adoptopenjdk/openjdk8
VOLUME /tmp
#ENV JAVA_OPTS="-Dcom.sun.management.jmxremote.port=39083 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
ENV JAVA_OPTS=""
ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
COPY localtime /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone
COPY hello-biz/target/hello-biz-*.jar app.jar
COPY hello-biz/lib/libsapjco3.so /usr/local/lib/libsapjco3.so
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]

上述内容就是springboot项目接入sap与部署到docker遇到的问题有哪些,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI