2015-02-05 2 views
0

JBoss Wildfly에서 Spring 4, DataNucleus 4 및 Postgres 9를 사용하여 maven 다중 모듈 프로젝트를 만들었습니다. 작업을 함께 구성해야합니다. 그러나 이제 DataNucleus는 데이터베이스에서 테이블을 자동으로 생성하지 않습니다. 여기DataNucleus 자동 생성 테이블

"지속성"받는다는 모듈의 내 치어 :

@PersistenceCapable 
public class User { 

    @PrimaryKey 
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
    private Long id; 

    @Persistent 
    private String name; 

    public User() {} 

    public Long getId() { 
     return id; 
    } 

    public void setId(Long id) { 
     this.id = id; 
    } 

    public String getName() { 
     return name; 
    } 

    public void setName(String name) { 
     this.name = name; 
    } 
} 

내 JDOConfigure

@Configuration 
@EnableTransactionManagement 
public class JDOConfiguration{ 

    @Bean 
    public PersistenceManagerFactory persistenceManagerFactory() { 

     PersistenceManagerFactory persistenceManagerFactory = JDOHelper.getPersistenceManagerFactory("jdo.properties"); 

     return persistenceManagerFactory; 
    } 



    @Bean 
    public JdoTransactionManager JdoTransactionManager() { 
     JdoTransactionManager JdoTransactionManager = new JdoTransactionManager(); 
     JdoTransactionManager.setPersistenceManagerFactory(persistenceManagerFactory()); 
     return JdoTransactionManager; 
    } 

} 

및 jdo.properties 등을 봄

과 :이 사용자 엔티티

<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"> 
    <parent> 
     <artifactId>somem</artifactId> 
     <groupId>somem</groupId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 
    <modelVersion>4.0.0</modelVersion> 

    <artifactId>persistence</artifactId> 
    <packaging>jar</packaging> 

    <name>persistence</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>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> 
     </dependency> 
     <dependency> 
      <groupId>org.datanucleus</groupId> 
      <artifactId>datanucleus-api-jdo</artifactId> 
      <version>4.0.5</version> 
     </dependency> 
     <dependency> 
      <groupId>org.datanucleus</groupId> 
      <artifactId>datanucleus-rdbms</artifactId> 
      <version>4.0.7</version> 
     </dependency> 
     <dependency> 
      <artifactId>spring-orm</artifactId> 
      <groupId>org.springframework</groupId> 
      <version>${spring.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.postgresql</groupId> 
      <artifactId>postgresql</artifactId> 
      <version>9.3-1102-jdbc41</version> 
     </dependency> 
    </dependencies> 
</project> 

PersistenceManagerFactory의 구성 :

datanucleus.autoCreateSchema=true 
javax.jdo.PersistenceManagerFactoryClass=org.datanucleus.api.jdo.JDOPersistenceManagerFactory 
javax.jdo.option.ConnectionURL= jdbc:postgresql://localhost/somem 
javax.jdo.option.ConnectionUserName = dom 
javax.jdo.option.ConnectionPassword = dom 
javax.jdo.option.ConnectionDriverName = org.postgresql.Driver 

왜 데이터 핵이 데이터베이스에서 사용자 테이블을 만들지 않습니까?

내 출력 : migration guide from v3.x 의해 정의

/usr/lib/jvm/oracle/jdk1.7.0_21/bin/java -classpath /home/user/software/idea-IU-139.659.2/lib/idea_rt.jar:/home/user/software/idea-IU-139.659.2/lib/util.jar -Dfile.encoding=UTF-8 com.intellij.rt.execution.CommandLineWrapper /tmp/classpath0.tmp com.intellij.javaee.oss.process.JavaeeProcess 37134 com.intellij.javaee.oss.jboss.agent.JBoss71Agent 
/home/user/software/wildfly-8.2.0.Final/bin/standalone.sh 
[2015-02-06 03:23:19,788] Artifact admin:war: Server is not connected. Deploy is not available. 
========================================================================= 
[2015-02-06 03:23:19,789] Artifact web:war: Server is not connected. Deploy is not available. 

Detected server admin port: 9990 
    JBoss Bootstrap Environment 
Detected server http port: 8080 

    JBOSS_HOME: /home/user/software/wildfly-8.2.0.Final 

    JAVA: /usr/lib/jvm/oracle/jdk1.7.0_21/bin/java 

    JAVA_OPTS: -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true 

========================================================================= 

[0m03:23:18,776 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final 
[0m[0m03:23:19,437 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final 
[0m[0m03:23:19,640 INFO [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.2.0.Final "Tweek" starting 
[0m[0m03:23:21,824 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http) 
[0m[0m03:23:21,854 INFO [org.xnio] (MSC service thread 1-1) XNIO version 3.3.0.Final 
[0m[0m03:23:21,881 INFO [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.3.0.Final 
[0m[0m03:23:21,918 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors 
[0m[0m03:23:21,922 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem. 
[0m[0m03:23:21,965 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main] 
[0m[0m03:23:21,982 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem 
[0m[0m03:23:21,985 INFO [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem 
[0m[0m03:23:21,988 INFO [org.jboss.as.security] (MSC service thread 1-4) JBAS013170: Current PicketBox version=4.0.21.Final 
[0m[0m03:23:21,999 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3) 
[0m[33m03:23:22,016 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique. 
[0m[0m03:23:22,027 INFO [org.jboss.as.connector.logging] (MSC service thread 1-7) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final) 
[0m[0m03:23:22,051 INFO [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017502: Undertow 1.1.0.Final starting 
[0m[0m03:23:22,051 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.1.0.Final starting 
[0m[0m03:23:22,061 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) JBAS010417: Started Driver service with driver-name = h2 
[0m[0m03:23:22,070 INFO [org.jboss.as.naming] (MSC service thread 1-8) JBAS011802: Starting Naming Service 
[0m[0m03:23:22,071 INFO [org.jboss.as.mail.extension] (MSC service thread 1-8) JBAS015400: Bound mail session [java:jboss/mail/Default] 
[0m[0m03:23:22,072 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension 
[0m[0m03:23:22,126 INFO [org.jboss.remoting] (MSC service thread 1-1) JBoss Remoting version 4.0.6.Final 
[0m[0m03:23:22,394 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path /home/user/software/wildfly-8.2.0.Final/welcome-content 
[0m[0m03:23:22,472 INFO [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017525: Started server default-server. 
[0m[0m03:23:22,489 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) JBAS017531: Host default-host starting 
[0m[0m03:23:22,645 INFO [org.wildfly.extension.undertow] (MSC service thread 1-8) JBAS017519: Undertow HTTP listener default listening on /127.0.0.1:8080 
[0m[0m03:23:23,195 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-6) JBAS015012: Started FileSystemDeploymentService for directory /home/user/software/wildfly-8.2.0.Final/standalone/deployments 
[0m[0m03:23:23,205 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS] 
[0m[0m03:23:23,562 INFO [org.jboss.ws.common.management] (MSC service thread 1-4) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final 
[0m[0m03:23:23,777 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management 
[0m[0m03:23:23,778 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990 
[0m[0m03:23:23,779 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 5650ms - Started 184 of 234 services (82 services are lazy, passive or on-demand) 
[0mConnected to server 
[2015-02-06 03:23:23,964] Artifact admin:war: Artifact is being deployed, please wait... 
[2015-02-06 03:23:23,965] Artifact web:war: Artifact is being deployed, please wait... 
[0m03:23:24,384 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015876: Starting deployment of "admin.war" (runtime-name: "admin.war") 
[0m[0m03:23:24,849 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017534: Registered web context: /admin 
[0m[0m03:23:25,335 INFO [org.jboss.as.server] (management-handler-thread - 3) JBAS018559: Deployed "admin.war" (runtime-name : "admin.war") 
[0m[2015-02-06 03:23:25,366] Artifact admin:war: Artifact is deployed successfully 
[2015-02-06 03:23:25,366] Artifact admin:war: Deploy took 1,402 milliseconds 
[0m03:23:25,632 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "web.war" (runtime-name: "web.war") 
[0m[33m03:23:26,995 WARN [org.jboss.as.ee] (MSC service thread 1-2) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause) 
[0m[33m03:23:27,005 WARN [org.jboss.as.ee] (MSC service thread 1-2) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause) 
[0m[0m03:23:27,084 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) JBAS010404: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.3) 
[0m[0m03:23:27,102 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) JBAS010417: Started Driver service with driver-name = web.war_org.postgresql.Driver_9_3 
[0m[0m03:23:27,140 INFO [io.undertow.servlet] (MSC service thread 1-4) Spring WebApplicationInitializers detected on classpath: [[email protected]] 
[0m[0m03:23:27,193 INFO [stdout] (MSC service thread 1-4) test222 
[0m[0m03:23:27,205 INFO [io.undertow.servlet] (MSC service thread 1-4) Initializing Spring root WebApplicationContext 
[0m[0m03:23:27,208 INFO [org.springframework.web.context.ContextLoader] (MSC service thread 1-4) Root WebApplicationContext: initialization started 
[0m[0m03:23:27,279 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (MSC service thread 1-4) Refreshing Root WebApplicationContext: startup date [Fri Feb 06 03:23:27 ICT 2015]; root of context hierarchy 
[0m[0m03:23:27,352 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (MSC service thread 1-4) Registering annotated classes: [class somem.persistence.config.JDOConfiguration] 
[0m[0m03:23:27,523 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (MSC service thread 1-4) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 
[0m[0m03:23:28,409 INFO [stdout] (MSC service thread 1-4) test system 
[0m[0m03:23:28,451 INFO [org.springframework.web.context.ContextLoader] (MSC service thread 1-4) Root WebApplicationContext: initialization completed in 1243 ms 
[0m[0m03:23:28,454 INFO [io.undertow.servlet] (MSC service thread 1-4) Initializing Spring FrameworkServlet 'dispatcher' 
[0m[0m03:23:28,454 INFO [org.springframework.web.servlet.DispatcherServlet] (MSC service thread 1-4) FrameworkServlet 'dispatcher': initialization started 
[0m[0m03:23:28,458 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (MSC service thread 1-4) Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Fri Feb 06 03:23:28 ICT 2015]; parent: Root WebApplicationContext 
[0m[0m03:23:28,460 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (MSC service thread 1-4) Registering annotated classes: [class somem.web.configuration.WebConfiguration] 
[0m[0m03:23:28,600 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (MSC service thread 1-4) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 
[0m[0m03:23:28,844 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (MSC service thread 1-4) Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String somem.web.controller.MainController.test(javax.servlet.http.HttpServletResponse) 
[0m[0m03:23:28,890 INFO [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (MSC service thread 1-4) Mapped URL path [/resources/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 
[0m[0m03:23:28,902 INFO [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (MSC service thread 1-4) Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler] 
[0m[0m03:23:29,235 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-4) HV000001: Hibernate Validator 5.1.3.Final 
[0m[0m03:23:29,328 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter] (MSC service thread 1-4) Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Fri Feb 06 03:23:28 ICT 2015]; parent: Root WebApplicationContext 
[0m[0m03:23:29,414 INFO [org.springframework.web.servlet.DispatcherServlet] (MSC service thread 1-4) FrameworkServlet 'dispatcher': initialization completed in 960 ms 
[0m[0m03:23:29,414 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017534: Registered web context: /web 
[0m[0m03:23:29,672 INFO [org.jboss.as.server] (management-handler-thread - 1) JBAS018559: Deployed "web.war" (runtime-name : "web.war") 
[0m[2015-02-06 03:23:29,708] Artifact web:war: Artifact is deployed successfully 
[2015-02-06 03:23:29,708] Artifact web:war: Deploy took 5,743 milliseconds 
+0

답이 문제를 해결한다고 가정하면 "수락"으로 표시해야합니다. 그렇지 않으면 해결되지 않은 것을 말할 필요가 있습니다. –

답변

0

datanucleus.autoCreateSchema는 DataNucleus 4.0 (the properties doc 참조)에서 유효한 특성이 아니다. datanucleus.schema.autoCreateAll을 사용하면 더 의미가 있습니다.