maven JTDS类未找到异常

blmhpbnm  于 2022-12-17  发布在  Maven
关注(0)|答案(2)|浏览(165)

我厌倦了谷歌搜索此错误。请帮助我。我发现建议添加jtds-1.3.1.jar到类路径或编辑您的web.xml。
请告诉我如何才能做到这一点?我使用的想法,Maven,Gwt和希望连接到mssql 2008快捷。

java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Drive
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:260)

(笑声)
http://maven.apache.org/maven-v4_0_0.xsd〉4.0.0版本

<groupId>gr1</groupId>
<artifactId>art1</artifactId>
<version>1.0-SNAPSHOT</version>

<packaging>war</packaging>

<name>search</name>

<properties>
    <gwt.version>2.7.0</gwt.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <web.xml.path>src/main/webapp/WEB-INF/web.xml</web.xml.path>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <version>${gwt.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-servlet</artifactId>
        <version>${gwt.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.ow2.asm</groupId>
        <artifactId>asm</artifactId>
        <version>5.0.3</version>
    </dependency>
    <dependency>
        <groupId>com.cloudbees.thirdparty</groupId>
        <artifactId>vijava</artifactId>
        <version>5.5-beta</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.jtds</groupId>
        <artifactId>jtds</artifactId>
        <version>1.3.1</version>
    </dependency>
</dependencies>

<build>
    <finalName>adsearch</finalName>
</build>

<profiles>
    <!-- LOCAL TOMCAT DEPLOY  -->
    <profile>
        <id>Local Tomcat</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <server>localhost</server>
                        <url>http://localhost:8080/manager/text</url>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>gwt-maven-plugin</artifactId>
                    <version>${gwt.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
        </build>
    </profile>

    <!-- PRODUCTION TOMCAT DEPLOY  -->
    <profile>
        <id>Production Tomcat</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>gwt-maven-plugin</artifactId>
                    <version>${gwt.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
        </build>
    </profile>

</profiles>

k4emjkb1

k4emjkb11#

检查在执行Class.forName(...)时是否指定了net.sourceforge.jtds.jdbc.Driver而不是net.sourceforge.jtds.jdbc.Drive

g0czyy6m

g0czyy6m2#

在项目pom中,不要添加依赖项,只需将jtds-1.3.1.jar复制到Tomcat服务器的lib文件夹中

相关问题