Adding External JARs to Openshift

2019-05-09 09:49发布

I have a pretty basic Java web application (created using Eclipse openshift plugin). The app runs fine on the OpenShift server. Now I need to use an external JAR library for JSON parsing and creation in Java. I can't understand my way around how to add that JAR to openshift server.

I went to project properties>>BuildPath>>Add external JAR. While that does import the JAR, it does not work on openshift server and gives error relating to that file's import (NoClassDefFound, I guess). Could you tell me how to import external jars into openshift project?

3条回答
男人必须洒脱
2楼-- · 2019-05-09 10:25

You can add the jar as a dependency in your pom.xml file. This will cause the jar to be included in your war. If the jar is not available in a public maven repo, please see here: http://www.billdecoste.net/?p=16

查看更多
孤傲高冷的网名
3楼-- · 2019-05-09 10:29

Since we use Maven for the build process, all you have to do is add it as a dependency in your pom.xml

Here is an example that adds a mongo driver

https://github.com/thesteve0/openshift-mongo-spatial-jee6/blob/master/pom.xml

Look under the dependencies tag

查看更多
相关推荐>>
4楼-- · 2019-05-09 10:39

[Updates in 2017] You might want to take a look at this link from OpenShift itself. It includes information about adding jars with and without maven dependencies.

查看更多
登录 后发表回答