我正在尝试使用Datanucleus作为数据库抽象来创建一个maven项目。但是,当我尝试mvn datanucleus:schema-create
时,我收到以下错误:
[ERROR] --------------------
[ERROR] Standard error from the DataNucleus tool + org.datanucleus.store.schema.SchemaTool :
[ERROR] --------------------
[ERROR] Error: Could not find or load main class org.datanucleus.store.schema.SchemaTool
pom.xml文件中的相关部分是:
<dependencies>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>4.0.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!-- <version>3.2</version> -->
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>4.0.0-release</version>
<configuration>
<api>JDO</api>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
persistence.xml文件位于/src/main/resources/META-INF/persistence.xml中,包含以下内容:
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd” 版本= “2.0” &GT;
<!-- JDO tutorial "unit" -->
<persistence-unit name="Tutorial">
<class>a.b.c.MyClass</class>
<exclude-unlisted-classes />
<properties>
<property name="javax.jdo.option.PersistenceUnitName" value="Tutorial" />
<property name="javax.jdo.option.ConnectionURL" value="jdbc:mysql://localhost/mydb" />
<property name="javax.jdo.option.ConnectionDriverName"
value="com.mysql.jdbc.Driver" />
<property name="javax.jdo.option.ConnectionUserName" value="myuser" />
<property name="javax.jdo.option.ConnectionPassword" value="mypass" />
<property name="datanucleus.schema.autoCreateAll" value="true" />
<property name="datanucleus.schema.validateTables" value="true" />
<property name="datanucleus.schema.validateConstraints"
value="true" />
<property name="javax.jdo.PersistenceManagerFactoryClass"
value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory" />
</properties>
</persistence-unit>
对于未经训练的眼睛,看起来一切都已到位,但它不起作用。
答案 0 :(得分:1)
也许你的<scope>runtime</scope>
导致了这个问题,因为那个jar包含了这个类。无论是否可以在命令行上轻松启用Maven debug --debug
,并查看CLASSPATH中该操作的内容。