我正在尝试使用maven创建一个jar文件。我已经从CA Pam导入了我正在开发的应用程序的库。但是,每当我将依赖项导入到maven中,然后将其打包到jar文件中时。它给了我这个错误
例外
Exception in thread "main" java.lang.NoClassDefFoundError:com/cloakware/cspm/cient/CSPMClient
at Driver.main(Driver.java:12)
Caused by: java.lang.ClassNotFoundException: com.cloakware.cspm.client.CSPMClient
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinCl
ssLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(
lassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 1 more
Java代码
import com.cloakware.cspm.client.CSPMClient;
public class Driver {
public static void main(String[] args) {
try {
//initialize
String targetAlias = "emc_grab";
String bypassCache = "true";
CSPMClient testInterface = new CSPMClient(targetAlias,true);
//get the result
String statusCode = testInterface.getStatusCode();
String userId = testInterface.getUserId();
String password = testInterface.getPassword();
String xmlData = testInterface.getXMLData();
System.out.println("Status Code: " + statusCode);
System.out.println("UsedId: " + userId);
System.out.println("Password: " + password);
System.out.println("XML Data: " + xmlData);
//set the return value
if ( statusCode.equals("400") ) {
System.out.println("PASSED");
System.exit(0);
} else {
System.out.println("FAILED");
System.exit(Integer.parseInt(statusCode));
}
} catch (Exception e) {
e.printStackTrace();
System.exit(100);
}
}
环境变量
PATH=C:\cspm\cloakware\cspmclient\lib
我目前正在使用Intellij,我花了很多天弄清楚它为什么不起作用。另外,下面是我的pom.xml文件
Pom
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.harriott</groupId>
<artifactId>GrabTest</artifactId>
<version>1.0</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>Driver</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>CommonLogging</artifactId>
<version>1.00</version>
</dependency>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>CommonsNet</artifactId>
<version>1.00</version>
</dependency>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>cwjcafips</artifactId>
<version>1.00</version>
</dependency>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>cwjssefips</artifactId>
<version>1.00</version>
</dependency>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>MortbayJetty</artifactId>
<version>1.00</version>
</dependency>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>JavaxServlet</artifactId>
<version>1.00</version>
</dependency>
<dependency>
<groupId>com.cloakware.cspm.client</groupId>
<artifactId>CSPMClient</artifactId>
<version>1.00</version>
</dependency>
</dependencies>
</project>