配置错误.连接到数据库时找不到类[org.apache.derby.jdbc.EmbeddedDriver] [英] Configuration error. Class [org.apache.derby.jdbc.EmbeddedDriver] not found while connecting to DB

查看:219
本文介绍了配置错误.连接到数据库时找不到类[org.apache.derby.jdbc.EmbeddedDriver]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用命令mvn exec:javacmd运行我的应用程序.我的Persistence.xml属性是:

I am using the command mvn exec:java to run my application from cmd.My Persistence.xml properties are is :

<properties>
        <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
        <property name="javax.persistence.jdbc.url" value="jdbc:derby:DB;create=true" />
        <property name="javax.persistence.jdbc.user" value="test" />
        <property name="javax.persistence.jdbc.password" value="test" />

        <!-- EclipseLink should create the database schema automatically -->
        <property name="eclipselink.ddl-generation" value="create-tables" />
        <property name="eclipselink.ddl-generation.output-mode"
            value="database" />
        <property name="connection.autocommit" value="false"/>
    </properties>

和我的pom.xml依赖项以及构建属性是:-

and my pom.xml dependency and build properties are :-

 <dependencies>
        <dependency>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>eclipselink</artifactId>
    <version>2.5.0</version>
</dependency>
    <dependency>
        <groupId>org.glassfish.jersey.connectors</groupId>
        <artifactId>jersey-grizzly-connector</artifactId>
        <version>2.16</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-grizzly2-http</artifactId>
        <version>2.16</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-grizzly2-servlet</artifactId>
        <version>2.16</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.grizzly</groupId>
        <artifactId>grizzly-framework</artifactId>
        <version>2.3.18</version>
    </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <inherited>true</inherited>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>com.example.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

如果使用run as java application运行eclipse中的主类,则运行良好,但使用命令mvn exec:java会给出配置错误错误.找不到类[org.apache.derby.jdbc.EmbeddedDriver].

if the run the main class in eclipse using run as java application it runs fine but using the command mvn exec:java gives the error of Configuration error. Class [org.apache.derby.jdbc.EmbeddedDriver] not found.

推荐答案

pom.xml中缺少使用Derby驱动程序的库. 尝试将其添加到您的pom.xml中:

You are missing library with Derby driver in your pom.xml. Try to add this in your pom.xml:

<dependency>
    <groupId>org.apache.derby</groupId>
    <artifactId>derbyclient</artifactId>
    <version>10.11.1.1</version>
</dependency>

在eclipse中它可能正在运行,可能是因为您将驱动程序手动添加到了classpath.

In eclipse it is running probably because you added the driver manually to classpath.

这篇关于配置错误.连接到数据库时找不到类[org.apache.derby.jdbc.EmbeddedDriver]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆