好像这个问题how to add external jar to maven webapp project 但是当我试图改变时,没有任何事情发生。 这是我的pom.xml
-- pom.xml
<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.sk.JDBC</groupId>
<artifactId>basicAgain</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>basicAgain</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.33</version>
</dependency>
</dependencies>
</project>
-- #pom.xml
当我编译并在maven中运行时:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sk.JDBC.App.main(App.java:28)
有人可以帮忙吗?
我是英语和Maven的新人,让我感到很生气:)
- 编辑
我甚至使用这些maven命令安装,但不工作:
mvn install:install-file -Dfile = src \ libraries \ mysql-connector-java-5.1.33.jar -DgroupId=mysql -DartifactId=mysql-connector-java -Dversion=5.1.33 -Dpackaging=jar