在持久化瞬态实体之后,Hibernate ORM会在刷新时产生不需要的SQL更新

时间:2016-02-15 08:33:38

标签: java sql hibernate orm

我有通过JPA注释映射的父子实体:

我创建父实体的新实例,添加一些字段并从JPA提供程序调用persist方法。我有不必要的SQL更新。 为什么冬眠会产生它?

Hibernate: insert into field_type (id) values (?)
Hibernate: insert into template (id, client_id, name) values (default, ?, ?)
Hibernate: select template_f_.id from field_type template_f_ where template_f_.id=?
Hibernate: insert into field (id, field_name_id, operation_template_id, field_value) values (default, ?, ?, ?)
(!)  Hibernate: update field set operation_template_id=? where id=?

包含子类的类模板:

     package com.example;




     import javax.persistence.*;
     import javax.persistence.CascadeType;
     import javax.persistence.Entity;
     import javax.persistence.Table;
     import java.util.*;

     @Entity
     @Table(name = "TEMPLATE")
     public class Template    {

         @Id
         @GeneratedValue(strategy = GenerationType.IDENTITY)
         @Column(name = "ID")
         private Long id;

         @Column(name = "CLIENT_ID", updatable = false)
         private Long clientId;

         @Column(name = "NAME")
         private String name;


         @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
         @JoinColumn(name = "OPERATION_TEMPLATE_ID", referencedColumnName = "ID")
         private Set<Field> fields = new HashSet<>();


         public Long getId() {
             return id;
         }

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

         public Long getClientId() {
             return clientId;
         }

         public void setClientId(Long clientId) {
             this.clientId = clientId;
         }

         public String getName() {
             return name;
         }

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



         public Set<Field> getFields() {
             return fields;
         }




         @Entity(name = "Field")
         @Table(name = "FIELD")
         public static class Field   {

             @Id
             @GeneratedValue(strategy = GenerationType.IDENTITY)
             @Column(name = "ID")
             private Long id;

             @OneToOne(fetch = FetchType.LAZY, optional = false)
             @JoinColumn(name = "FIELD_NAME_ID", nullable = false)
             private FieldType name;

             @ManyToOne(fetch = FetchType.LAZY, optional = false)
             @JoinColumn(name = "OPERATION_TEMPLATE_ID", nullable = false)
             private Template template;


             @Column(name = "FIELD_VALUE", nullable = false)
             private String value;

             public Long getId() {
                 return id;
             }

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

             public FieldType getName() {
                 return name;
             }

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

             public Template getTemplate() {
                 return template;
             }

             public void setTemplate(Template template) {
                 this.template = template;
             }

             public String getValue() {
                 return value;
             }

             public void setValue(String value) {
                 this.value = value;
             }

         }

         @Entity
         @Table(name = "FIELD_TYPE")
         public static class FieldType   {


             @Id
             @Column(name = "ID")
             private Long id;


             @Column(name = "TYPE_NAME", insertable = false, updatable = false)
             private String name;

             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;
             }



         }


     }

道类

@Repository
public class FieldTypeDao {
    @PersistenceContext
    protected EntityManager entityManager;

    @Transactional
    public void saveAsNew(Template.FieldType fieldType) {
        entityManager.persist(fieldType);
        entityManager.flush();
    }
}

@Repository
public class TemplateDao {

    @PersistenceContext
    protected EntityManager entityManager;

    @Transactional
    public void saveAsNew(Template template) {
        entityManager.persist(template);
        entityManager.flush();
    }
}

配置和主要课程

package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoHbnApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoHbnApplication.class, args);
    }
}

测试:

package com.example;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = DemoHbnApplication.class)
public class TemplateDaoTest {

    @Autowired
    private TemplateDao  templateDao;
    @Autowired
    private FieldTypeDao fieldTypeDao;


    @Test
    public void testSave() throws Exception {
        Template template = new Template();
        template.setName("test template name");
        Template.Field     field     = new Template.Field();
        Template.FieldType fieldType = new Template.FieldType();
        fieldType.setId(1L);
        fieldType.setName("example type");
        fieldTypeDao.saveAsNew(fieldType);
        field.setName(fieldType);
        field.setValue("123");
        field.setTemplate(template);
        template.getFields().add(field);

        templateDao.saveAsNew(template);

    }
}

的部分测试输出
  

logging.level.org.hibernate:TRACE

2016-02-15 11:30:03.686 DEBUG 8596 --- [           main] org.hibernate.SQL                        : insert into field (id, field_name_id, operation_template_id, field_value) values (default, ?, ?, ?)
Hibernate: insert into field (id, field_name_id, operation_template_id, field_value) values (default, ?, ?, ?)
2016-02-15 11:30:03.687 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Registering statement [org.hsqldb.jdbc.JDBCPreparedStatement@6dc9da2d[sql=[insert into field (id, field_name_id, operation_template_id, field_value) values (default, ?, ?, ?)], parameters=[[null], [null], [null]]]]
2016-02-15 11:30:03.687 TRACE 8596 --- [           main] o.h.p.entity.AbstractEntityPersister     : Dehydrating entity: [com.example.Template$Field#<null>]
2016-02-15 11:30:03.687 TRACE 8596 --- [           main] o.hibernate.engine.spi.IdentifierValue   : ID unsaved-value strategy UNDEFINED
2016-02-15 11:30:03.687 TRACE 8596 --- [           main] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2016-02-15 11:30:03.687 TRACE 8596 --- [           main] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [BIGINT] - [1]
2016-02-15 11:30:03.687 TRACE 8596 --- [           main] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [VARCHAR] - [123]
2016-02-15 11:30:03.688 DEBUG 8596 --- [           main] o.h.id.IdentifierGeneratorHelper         : Natively generated identity: 1
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Releasing result set [org.hsqldb.jdbc.JDBCResultSet@1d408060]
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Closing result set [org.hsqldb.jdbc.JDBCResultSet@1d408060]
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Releasing statement [org.hsqldb.jdbc.JDBCPreparedStatement@6dc9da2d[sql=[insert into field (id, field_name_id, operation_template_id, field_value) values (default, ?, ?, ?)], parameters=[[1], [1], [123]]]]
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Closing prepared statement [org.hsqldb.jdbc.JDBCPreparedStatement@6dc9da2d[sql=[insert into field (id, field_name_id, operation_template_id, field_value) values (default, ?, ?, ?)], parameters=[[1], [1], [123]]]]
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Starting after statement execution processing [ON_CLOSE]
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] o.h.a.i.UnresolvedEntityInsertActions    : No unresolved entity inserts that depended on [[com.example.Template$Field#1]]
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Done cascade ACTION_PERSIST_SKIPLAZY for collection: com.example.Template.fields
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Done processing cascade ACTION_PERSIST_SKIPLAZY for: com.example.Template
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] o.h.a.i.UnresolvedEntityInsertActions    : No entity insert actions have non-nullable, transient entity dependencies.
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Flushing session
2016-02-15 11:30:03.688 DEBUG 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Processing flush-time cascades
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Cascade ACTION_PERSIST_ON_FLUSH for collection: com.example.Template.fields
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] o.hibernate.engine.spi.CascadingAction   : Cascading to persist on flush: com.example.Template$Field
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] o.h.e.i.AbstractSaveEventListener        : Persistent instance of: com.example.Template$Field
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] o.h.e.i.DefaultPersistEventListener      : Ignoring persistent instance
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template$Field
2016-02-15 11:30:03.688 TRACE 8596 --- [           main] o.hibernate.engine.spi.IdentifierValue   : ID unsaved-value strategy UNDEFINED
2016-02-15 11:30:03.689 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Done processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template$Field
2016-02-15 11:30:03.689 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template$Field
2016-02-15 11:30:03.689 TRACE 8596 --- [           main] o.hibernate.engine.spi.IdentifierValue   : ID unsaved-value strategy UNDEFINED
2016-02-15 11:30:03.689 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Done processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template$Field
2016-02-15 11:30:03.689 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Done cascade ACTION_PERSIST_ON_FLUSH for collection: com.example.Template.fields
2016-02-15 11:30:03.689 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Done processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template
2016-02-15 11:30:03.689 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template$Field
2016-02-15 11:30:03.689 TRACE 8596 --- [           main] o.hibernate.engine.spi.IdentifierValue   : ID unsaved-value strategy UNDEFINED
2016-02-15 11:30:03.689 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Done processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template$Field
2016-02-15 11:30:03.689 DEBUG 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Dirty checking collections
2016-02-15 11:30:03.689 TRACE 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Flushing entities and processing referenced collections
2016-02-15 11:30:03.691 DEBUG 8596 --- [           main] o.hibernate.engine.internal.Collections  : Collection found: [com.example.Template.fields#1], was: [<unreferenced>] (initialized)
2016-02-15 11:30:03.691 TRACE 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Processing unreferenced collections
2016-02-15 11:30:03.691 TRACE 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Scheduling collection removes/(re)creates/updates
2016-02-15 11:30:03.692 DEBUG 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects
2016-02-15 11:30:03.692 DEBUG 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Flushed: 1 (re)creations, 0 updates, 0 removals to 1 collections
2016-02-15 11:30:03.692 DEBUG 8596 --- [           main] o.hibernate.internal.util.EntityPrinter  : Listing entities:
2016-02-15 11:30:03.693 DEBUG 8596 --- [           main] o.hibernate.internal.util.EntityPrinter  : com.example.Template{clientId=null, name=test template name, id=1, fields=[com.example.Template$Field#1]}
2016-02-15 11:30:03.693 DEBUG 8596 --- [           main] o.hibernate.internal.util.EntityPrinter  : com.example.Template$Field{template=com.example.Template#1, name=com.example.Template$FieldType#1, id=1, value=123}
2016-02-15 11:30:03.693 TRACE 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Executing flush
2016-02-15 11:30:03.693 DEBUG 8596 --- [           main] o.h.p.c.AbstractCollectionPersister      : Inserting collection: [com.example.Template.fields#1]
2016-02-15 11:30:03.693 TRACE 8596 --- [           main] o.h.e.j.batch.internal.BatchBuilderImpl  : Building batch [size=1]
2016-02-15 11:30:03.693 DEBUG 8596 --- [           main] org.hibernate.SQL                        : update field set operation_template_id=? where id=?
Hibernate: update field set operation_template_id=? where id=?
2016-02-15 11:30:03.693 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Registering statement [org.hsqldb.jdbc.JDBCPreparedStatement@48df4071[sql=[update field set operation_template_id=? where id=?], parameters=[[null], [null]]]]
2016-02-15 11:30:03.693 TRACE 8596 --- [           main] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2016-02-15 11:30:03.694 TRACE 8596 --- [           main] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [BIGINT] - [1]
2016-02-15 11:30:03.695 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Releasing statement [org.hsqldb.jdbc.JDBCPreparedStatement@48df4071[sql=[update field set operation_template_id=? where id=?], parameters=[[1], [1]]]]
2016-02-15 11:30:03.695 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Closing prepared statement [org.hsqldb.jdbc.JDBCPreparedStatement@48df4071[sql=[update field set operation_template_id=? where id=?], parameters=[[1], [1]]]]
2016-02-15 11:30:03.695 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Starting after statement execution processing [ON_CLOSE]
2016-02-15 11:30:03.695 DEBUG 8596 --- [           main] o.h.p.c.AbstractCollectionPersister      : Done inserting collection: 1 rows inserted
2016-02-15 11:30:03.695 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Starting after statement execution processing [ON_CLOSE]
2016-02-15 11:30:03.695 TRACE 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Post flush
2016-02-15 11:30:03.696 DEBUG 8596 --- [           main] o.h.e.t.spi.AbstractTransactionImpl      : committing
2016-02-15 11:30:03.696 TRACE 8596 --- [           main] org.hibernate.internal.SessionImpl       : Automatically flushing session
2016-02-15 11:30:03.696 TRACE 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Flushing session
2016-02-15 11:30:03.696 DEBUG 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Processing flush-time cascades
2016-02-15 11:30:03.696 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template
2016-02-15 11:30:03.696 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Cascade ACTION_PERSIST_ON_FLUSH for collection: com.example.Template.fields
2016-02-15 11:30:03.696 TRACE 8596 --- [           main] o.hibernate.engine.spi.CascadingAction   : Cascading to persist on flush: com.example.Template$Field
2016-02-15 11:30:03.696 TRACE 8596 --- [           main] o.h.e.i.AbstractSaveEventListener        : Persistent instance of: com.example.Template$Field
2016-02-15 11:30:03.696 TRACE 8596 --- [           main] o.h.e.i.DefaultPersistEventListener      : Ignoring persistent instance
2016-02-15 11:30:03.696 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template$Field
2016-02-15 11:30:03.696 TRACE 8596 --- [           main] o.hibernate.engine.spi.IdentifierValue   : ID unsaved-value strategy UNDEFINED
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Done processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template$Field
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template$Field
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] o.hibernate.engine.spi.IdentifierValue   : ID unsaved-value strategy UNDEFINED
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Done processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template$Field
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Done cascade ACTION_PERSIST_ON_FLUSH for collection: com.example.Template.fields
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Done processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template$Field
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] o.hibernate.engine.spi.IdentifierValue   : ID unsaved-value strategy UNDEFINED
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] org.hibernate.engine.internal.Cascade    : Done processing cascade ACTION_PERSIST_ON_FLUSH for: com.example.Template$Field
2016-02-15 11:30:03.697 DEBUG 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Dirty checking collections
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Flushing entities and processing referenced collections
2016-02-15 11:30:03.697 DEBUG 8596 --- [           main] o.hibernate.engine.internal.Collections  : Collection found: [com.example.Template.fields#1], was: [com.example.Template.fields#1] (initialized)
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Processing unreferenced collections
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Scheduling collection removes/(re)creates/updates
2016-02-15 11:30:03.697 DEBUG 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects
2016-02-15 11:30:03.697 DEBUG 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Flushed: 0 (re)creations, 0 updates, 0 removals to 1 collections
2016-02-15 11:30:03.697 DEBUG 8596 --- [           main] o.hibernate.internal.util.EntityPrinter  : Listing entities:
2016-02-15 11:30:03.697 DEBUG 8596 --- [           main] o.hibernate.internal.util.EntityPrinter  : com.example.Template{clientId=null, name=test template name, id=1, fields=[com.example.Template$Field#1]}
2016-02-15 11:30:03.697 DEBUG 8596 --- [           main] o.hibernate.internal.util.EntityPrinter  : com.example.Template$Field{template=com.example.Template#1, name=com.example.Template$FieldType#1, id=1, value=123}
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Executing flush
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Starting after statement execution processing [ON_CLOSE]
2016-02-15 11:30:03.697 TRACE 8596 --- [           main] o.h.e.i.AbstractFlushingEventListener    : Post flush
2016-02-15 11:30:03.698 TRACE 8596 --- [           main] org.hibernate.internal.SessionImpl       : before transaction completion
2016-02-15 11:30:03.698 DEBUG 8596 --- [           main] o.h.e.t.internal.jdbc.JdbcTransaction    : committed JDBC Connection
2016-02-15 11:30:03.698 DEBUG 8596 --- [           main] o.h.e.t.internal.jdbc.JdbcTransaction    : re-enabling autocommit
2016-02-15 11:30:03.698 TRACE 8596 --- [           main] o.h.e.t.i.TransactionCoordinatorImpl     : after transaction completion
2016-02-15 11:30:03.698 TRACE 8596 --- [           main] org.hibernate.internal.SessionImpl       : after transaction completion
2016-02-15 11:30:03.698 TRACE 8596 --- [           main] org.hibernate.internal.SessionImpl       : Closing session
2016-02-15 11:30:03.698 TRACE 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Closing JDBC container [org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl@5f14761c]
2016-02-15 11:30:03.698 DEBUG 8596 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : HHH000420: Closing un-released batch
2016-02-15 11:30:03.698 TRACE 8596 --- [           main] o.h.e.j.internal.LogicalConnectionImpl   : Closing logical connection
2016-02-15 11:30:03.698 DEBUG 8596 --- [           main] o.h.e.j.internal.LogicalConnectionImpl   : Releasing JDBC connection
2016-02-15 11:30:03.698 DEBUG 8596 --- [           main] o.h.e.j.internal.LogicalConnectionImpl   : Released JDBC connection
2016-02-15 11:30:03.698 TRACE 8596 --- [           main] o.h.e.j.internal.LogicalConnectionImpl   : Logical connection closed

最后,pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>com.example</groupId>
    <artifactId>demohbn</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo-hbn</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
            <version>RELEASE</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

0 个答案:

没有答案