简体   繁体   English

将jar运行为docker映像并在其他Java应用程序中使用此jar

[英]Running a jar as docker image and using this jar in other java application

I have a jar that do some business functionality and developed as a standalone component. 我有一个执行某些业务功能的jar,并且是作为独立组件开发的。 Now I want to use it as a Microservice hosted as docker image. 现在,我想将其用作托管为docker映像的微服务。 I was able to create a docker image by following the tutorial as: https://dzone.com/articles/run-simple-jar-application-in-docker-container-1 我可以按照以下教程创建一个docker镜像: https : //dzone.com/articles/run-simple-jar-application-in-docker-container-1

Now I have two problems: 现在我有两个问题:

  1. How to call the methods of the classes in this Jar in other java applications 如何在其他Java应用程序中调用此Jar中的类的方法
  2. how to do the integration testing? 怎么做集成测试?

I am asking this as I need to take a decision if I should convert this JAR to a REST based application or it can be used as a Microservice in its actual (jar) based packaging. 我问这个问题是因为我需要决定是否应该将此JAR转换为基于REST的应用程序,或者可以将其用作基于其实际(jar)包装的微服务。

Thanks 谢谢

In the article it had 在文章中

CMD java -jar HelloWorld.jar

I want you to imagine the logical extension of hello world that takes arguments and can output "Hello Steve" instead. 我想让您想象一下hello世界的逻辑扩展,该逻辑扩展接受参数并可以输出“ Hello Steve”。

change that line to 将该行更改为

ENTRYPOINT ["java", "--jar", "HellowWorld.jar"]

and

CMD ["World"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM