Я пытаюсь создать проект maven с DataNucleus и MySQL. Однако, когда я пытаюсь построить и mvn datanucleus:schema-create
проекта, я получаю сбой. Я не могу понять, почему.DataNucleus, Maven, schema-create failed
Вот persistence.xml
класс, и он является присутствует в classes/META-INF
папке проекта постройки:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<!-- JDO tutorial "unit" -->
<persistence-unit name="Tutorial">
<class>hello.Counter</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.jdo.option.ConnectionURL" value="jdbc:mysql://localhost/glu" />
<property name="javax.jdo.option.ConnectionDriverName"
value="com.mysql.jdbc.Driver" />
<property name="javax.jdo.option.ConnectionUserName" value="root" />
<property name="javax.jdo.option.ConnectionPassword" value="root" />
<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>
</persistence>
Вот 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>ru.sf0.one</groupId>
<artifactId>two</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>glu</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<!-- <version>1.2.0</version> -->
</dependency>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<!-- scope>runtime</scope -->
<version>4.0.4</version>
</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>
<scope>runtime</scope>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-accessplatform-jdo-rdbms</artifactId>
<version>4.0.4</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<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>
<persistenceUnitName>Tutorial</persistenceUnitName>
<log4jConfiguration>${basedir}/src/main/resources/log4j.properties</log4jConfiguration>
<verbose>false</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
ошибка, что я получаю:
~>2015-02-23 00:26:55 DEBUG MetaData:58 - Class "hello.Counter" field "count" : Adding Meta-Data for field since it didnt appear in the Meta-Data definition.
~>2015-02-23 00:26:55 DEBUG MetaData:58 - Initialising all MetaData ...
~>2015-02-23 00:26:55 DEBUG MetaData:58 - Class "hello.Counter" : Initialising Meta-Data
~>2015-02-23 00:26:55 DEBUG MetaData:58 - MetaData Management : Load of Metadata complete
~>2015-02-23 00:26:55 DEBUG Datastore:58 - Creating StoreManager for datastore
~>2015-02-23 00:26:55 ERROR Datastore:125 - Exception thrown creating StoreManager. See the nested exception
There is no available StoreManager of type "jdbc". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType"
org.datanucleus.exceptions.NucleusUserException: There is no available StoreManager of type "jdbc". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType"
at org.datanucleus.NucleusContextHelper.createStoreManagerForProperties(NucleusContextHelper.java:223)
at org.datanucleus.PersistenceNucleusContextImpl.initialise(PersistenceNucleusContextImpl.java:433)
at org.datanucleus.store.schema.SchemaTool.getNucleusContextForMode(SchemaTool.java:693)
at org.datanucleus.store.schema.SchemaTool.main(SchemaTool.java:286)
~>2015-02-23 00:26:55 ERROR SchemaTool:125 - Error creating NucleusContext
There is no available StoreManager of type "jdbc". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType"
org.datanucleus.exceptions.NucleusUserException: There is no available StoreManager of type "jdbc". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType"
at org.datanucleus.NucleusContextHelper.createStoreManagerForProperties(NucleusContextHelper.java:223)
at org.datanucleus.PersistenceNucleusContextImpl.initialise(PersistenceNucleusContextImpl.java:433)
at org.datanucleus.store.schema.SchemaTool.getNucleusContextForMode(SchemaTool.java:693)
at org.datanucleus.store.schema.SchemaTool.main(SchemaTool.java:286)
An error was encountered creating a PersistenceManagerFactory : There is no available StoreManager of type "jdbc". Make sure that you have put the relevant DataNucleus store plugin in your CLASSPATH and if defining a connection via JNDI or DataSource you also need to provide persistence property "datanucleus.storeManagerType" - please consult the log for more information.
UPD Если я удалить <scope>runtime</scope>
ограничение из datanucleus-rdbms
, я получаю следующее сообщение об ошибке:
~>2015-02-23 12:07:34 DEBUG MetaData:58 - Class "hello.Counter" field "count" : Adding Meta-Data for field since it didnt appear in the Meta-Data definition.
~>2015-02-23 12:07:34 DEBUG MetaData:58 - Initialising all MetaData ...
~>2015-02-23 12:07:34 DEBUG MetaData:58 - Class "hello.Counter" : Initialising Meta-Data
~>2015-02-23 12:07:34 DEBUG MetaData:58 - MetaData Management : Load of Metadata complete
~>2015-02-23 12:07:34 DEBUG Datastore:58 - Creating StoreManager for datastore
~>2015-02-23 12:07:34 ERROR Datastore:125 - Exception thrown creating StoreManager. See the nested exception
Error creating transactional connection factory
org.datanucleus.exceptions.NucleusException: Error creating transactional connection factory
at org.datanucleus.store.AbstractStoreManager.registerConnectionFactory(AbstractStoreManager.java:219)
at org.datanucleus.store.AbstractStoreManager.<init>(AbstractStoreManager.java:163)
at org.datanucleus.store.rdbms.RDBMSStoreManager.<init>(RDBMSStoreManager.java:288)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.java:606)
at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:301)
at org.datanucleus.NucleusContextHelper.createStoreManagerForProperties(NucleusContextHelper.java:193)
at org.datanucleus.PersistenceNucleusContextImpl.initialise(PersistenceNucleusContextImpl.java:433)
at org.datanucleus.store.schema.SchemaTool.getNucleusContextForMode(SchemaTool.java:693)
at org.datanucleus.store.schema.SchemaTool.main(SchemaTool.java:286)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.java:606)
at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:330)
at org.datanucleus.store.AbstractStoreManager.registerConnectionFactory(AbstractStoreManager.java:205)
... 12 more
Caused by: java.lang.NullPointerException
at org.datanucleus.store.rdbms.ConnectionFactoryImpl.initialiseDataSources(ConnectionFactoryImpl.java:110)
at org.datanucleus.store.rdbms.ConnectionFactoryImpl.<init>(ConnectionFactoryImpl.java:82)
... 19 more
Nested Throwables StackTrace:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.java:606)
at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:330)
at org.datanucleus.store.AbstractStoreManager.registerConnectionFactory(AbstractStoreManager.java:205)
at org.datanucleus.store.AbstractStoreManager.<init>(AbstractStoreManager.java:163)
at org.datanucleus.store.rdbms.RDBMSStoreManager.<init>(RDBMSStoreManager.java:288)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.java:606)
at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:301)
at org.datanucleus.NucleusContextHelper.createStoreManagerForProperties(NucleusContextHelper.java:193)
at org.datanucleus.PersistenceNucleusContextImpl.initialise(PersistenceNucleusContextImpl.java:433)
at org.datanucleus.store.schema.SchemaTool.getNucleusContextForMode(SchemaTool.java:693)
at org.datanucleus.store.schema.SchemaTool.main(SchemaTool.java:286)
Caused by: java.lang.NullPointerException
at org.datanucleus.store.rdbms.ConnectionFactoryImpl.initialiseDataSources(ConnectionFactoryImpl.java:110)
at org.datanucleus.store.rdbms.ConnectionFactoryImpl.<init>(ConnectionFactoryImpl.java:82)
... 19 more
Почему бы не запустить учебное пособие на сайте DataNucleus, потому что это работает для меня, и только вы знаете, что вы изменили из него. Очевидно, что persistence.xml должен быть в META-INF из корня CLASSPATH, а если нет, то вы не даете ему знать, где находится ваша база данных. –
В папке _was_ META-INF, я назвал ее неправильной здесь в тексте. Кроме того, я добавил некоторые поля в pom, и теперь очевидно, что persistence.xml считывается и анализируется, однако шаг создания схемы не выполняется. Я подозреваю, что это может быть связано с тем, что я пытаюсь унаследовать родительский родитель. – Ibolit
@NeilStockton С вашей помощью я теперь несколько шагов от цели. Теперь я получаю «Нет доступного StoreManager типа« jdbc ».» Ошибка. Я обновил свой пост соответственно. Не могли бы вы помочь мне? – Ibolit