我正在创建一个春季启动应用程序,3个实体之间的关系很少。实体为Course
,Program
和Major
。
现在Course
包含Program
和Major
的列表(包括多对多)。此外Major
还有“计划”列表(也是多对多)。
以下是我的postgresql配置文件:
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=true
spring.database.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/rootdb
spring.datasource.username=postgres
spring.datasource.password=123
spring.jpa.hibernate.ddl-auto=create
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
以下是我的Course
实体:
@Entity
@Table(name = "course")
public class Course {
@Id
@Column(name = "course_code")
private String courseCode;
//other fields
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "course_major", joinColumns = @JoinColumn(name =
"course_code", referencedColumnName = "course_code"), inverseJoinColumns =
@JoinColumn(name = "major_uid", referencedColumnName = "major_uid"))
private Set<Major> majors;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "course_program", joinColumns = @JoinColumn(name =
"course_code", referencedColumnName = "course_code"), inverseJoinColumns =
@JoinColumn(name = "program_uid", referencedColumnName = "program_uid"))
private Set<Program> programs;
//getter-setters
}
关注我的Major
实体:
@Entity
@Table(name = "major")
public class Major extends BaseAuditingEntity {
@Id
@Column(name = "major_uid")
private String uid;
//other fields
@ManyToMany(mappedBy = "majors")
private Set<Course> courses;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "program_major", joinColumns = @JoinColumn(name = "major_uid", referencedColumnName = "major_uid"), inverseJoinColumns = @JoinColumn(name = "program_uid", referencedColumnName = "program_uid"))
private Set<Program> programs;
//getter-setters
}
以下是我的Program
实体:
@Entity
@Table(name = "program")
public class Program extends BaseAuditingEntity {
@Id
@Column(name = "program_uid")
private String uid;
//other fields
@ManyToMany(mappedBy = "programs")
private Set<Course> courses;
@ManyToMany(mappedBy = "programs")
private Set<Major> majors;
//getter-setters
}
完整的错误日志是:
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)
at com.toyota.aftersales.pqss.tten.courseservice.Application.main(Application.java:32)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1249)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:860)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:319)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 16 common frames omitted
Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: 1589370464
at org.hibernate.dialect.TypeNames.get(TypeNames.java:87)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:118)
at org.hibernate.dialect.Dialect.getTypeName(Dialect.java:330)
at org.hibernate.mapping.Column.getSqlType(Column.java:230)
at org.hibernate.mapping.Table.sqlCreateString(Table.java:512)
at org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:1071)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:126)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:517)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
... 24 common frames omitted
2018-03-21 12:09:23 [main] INFO o.s.b.l.ClasspathLoggingApplicationListener -
Application failed to start with classpath: [file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/resources.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/rt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/jsse.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/jce.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/charsets.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/jfr.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/ext/access-bridge-64.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/ext/cldrdata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/ext/dnsns.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/ext/jaccess.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/ext/jfxrt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/ext/localedata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/ext/nashorn.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/ext/sunec.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/ext/sunjce_provider.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/ext/sunmscapi.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/ext/sunpkcs11.jar, file:/C:/Program%20Files/Java/jdk1.8.0_161/jre/lib/ext/zipfs.jar, file:/C:/Users/Crest/Documents/course-mgmt-service/target/classes/, file:/C:/Users/Crest/Documents/pqss_shared/target/classes/, file:/C:/Users/Crest/.m2/repository/org/springframework/spring-context/4.2.6.RELEASE/spring-context-4.2.6.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/spring-aop/4.2.6.RELEASE/spring-aop-4.2.6.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/spring-beans/4.2.6.RELEASE/spring-beans-4.2.6.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/spring-expression/4.2.6.RELEASE/spring-expression-4.2.6.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/spring-web/4.2.6.RELEASE/spring-web-4.2.6.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/javax/validation/validation-api/2.0.0.Final/validation-api-2.0.0.Final.jar, file:/C:/Users/Crest/.m2/repository/com/fasterxml/jackson-xml-databind/0.6.2/jackson-xml-databind-0.6.2.jar, file:/C:/Users/Crest/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.9.2/jackson-mapper-asl-1.9.2.jar, file:/C:/Users/Crest/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.2/jackson-core-asl-1.9.2.jar, file:/C:/Users/Crest/.m2/repository/org/codehaus/jackson/jackson-xc/1.9.2/jackson-xc-1.9.2.jar, file:/C:/Users/Crest/.m2/repository/org/codehaus/woodstox/stax2-api/3.1.0/stax2-api-3.1.0.jar, file:/C:/Users/Crest/.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar, file:/C:/Users/Crest/.m2/repository/org/perf4j/perf4j/0.9.16/perf4j-0.9.16.jar, file:/C:/Users/Crest/.m2/repository/org/aspectj/aspectjweaver/1.8.9/aspectjweaver-1.8.9.jar, file:/C:/Users/Crest/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/C:/Users/Crest/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar, file:/C:/Users/Crest/.m2/repository/ch/qos/logback/logback-core/1.1.7/logback-core-1.1.7.jar, file:/C:/Users/Crest/.m2/repository/org/aspectj/aspectjrt/1.8.9/aspectjrt-1.8.9.jar, file:/C:/Users/Crest/.m2/repository/commons-jexl/commons-jexl/1.1/commons-jexl-1.1.jar, file:/C:/Users/Crest/.m2/repository/asm/asm/1.5.3/asm-1.5.3.jar, file:/C:/Users/Crest/.m2/repository/cglib/cglib/2.1_3/cglib-2.1_3.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/spring-aspects/4.2.6.RELEASE/spring-aspects-4.2.6.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7.jar, file:/C:/Users/Crest/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar, file:/C:/Users/Crest/Documents/tten-commons/target/classes/, file:/C:/Users/Crest/.m2/repository/io/springfox/springfox-swagger2/2.7.0/springfox-swagger2-2.7.0.jar, file:/C:/Users/Crest/.m2/repository/io/swagger/swagger-annotations/1.5.13/swagger-annotations-1.5.13.jar, file:/C:/Users/Crest/.m2/repository/io/swagger/swagger-models/1.5.13/swagger-models-1.5.13.jar, file:/C:/Users/Crest/.m2/repository/io/springfox/springfox-spi/2.7.0/springfox-spi-2.7.0.jar, file:/C:/Users/Crest/.m2/repository/io/springfox/springfox-core/2.7.0/springfox-core-2.7.0.jar, file:/C:/Users/Crest/.m2/repository/net/bytebuddy/byte-buddy/1.6.14/byte-buddy-1.6.14.jar, file:/C:/Users/Crest/.m2/repository/io/springfox/springfox-schema/2.7.0/springfox-schema-2.7.0.jar, file:/C:/Users/Crest/.m2/repository/io/springfox/springfox-swagger-common/2.7.0/springfox-swagger-common-2.7.0.jar, file:/C:/Users/Crest/.m2/repository/io/springfox/springfox-spring-web/2.7.0/springfox-spring-web-2.7.0.jar, file:/C:/Users/Crest/.m2/repository/org/reflections/reflections/0.9.11/reflections-0.9.11.jar, file:/C:/Users/Crest/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar, file:/C:/Users/Crest/.m2/repository/com/fasterxml/classmate/1.3.3/classmate-1.3.3.jar, file:/C:/Users/Crest/.m2/repository/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/plugin/spring-plugin-metadata/1.2.0.RELEASE/spring-plugin-metadata-1.2.0.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/mapstruct/mapstruct/1.1.0.Final/mapstruct-1.1.0.Final.jar, file:/C:/Users/Crest/.m2/repository/com/jayway/jsonpath/json-path/2.0.0/json-path-2.0.0.jar, file:/C:/Users/Crest/.m2/repository/net/minidev/json-smart/2.1.1/json-smart-2.1.1.jar, file:/C:/Users/Crest/.m2/repository/net/minidev/asm/1.0.2/asm-1.0.2.jar, file:/C:/Users/Crest/.m2/repository/io/springfox/springfox-swagger-ui/2.7.0/springfox-swagger-ui-2.7.0.jar, file:/C:/Users/Crest/.m2/repository/net/sf/dozer/dozer/5.5.1/dozer-5.5.1.jar, file:/C:/Users/Crest/.m2/repository/commons-beanutils/commons-beanutils/1.9.2/commons-beanutils-1.9.2.jar, file:/C:/Users/Crest/.m2/repository/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar, file:/C:/Users/Crest/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.21/jcl-over-slf4j-1.7.21.jar, file:/C:/Users/Crest/.m2/repository/postgresql/postgresql/9.1-901-1.jdbc4/postgresql-9.1-901-1.jdbc4.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/1.3.5.RELEASE/spring-boot-starter-data-jpa-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot-starter-aop/1.3.5.RELEASE/spring-boot-starter-aop-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/1.3.5.RELEASE/spring-boot-starter-jdbc-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/apache/tomcat/tomcat-jdbc/8.0.33/tomcat-jdbc-8.0.33.jar, file:/C:/Users/Crest/.m2/repository/org/apache/tomcat/tomcat-juli/8.0.33/tomcat-juli-8.0.33.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/spring-jdbc/4.2.6.RELEASE/spring-jdbc-4.2.6.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/data/spring-data-jpa/1.10.10.RELEASE/spring-data-jpa-1.10.10.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/data/spring-data-commons/1.12.10.RELEASE/spring-data-commons-1.12.10.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/spring-orm/4.2.6.RELEASE/spring-orm-4.2.6.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/spring-tx/4.2.6.RELEASE/spring-tx-4.2.6.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/hibernate/hibernate-core/4.3.11.Final/hibernate-core-4.3.11.Final.jar, file:/C:/Users/Crest/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar, file:/C:/Users/Crest/.m2/repository/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar, file:/C:/Users/Crest/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Final/jboss-transaction-api_1.2_spec-1.0.0.Final.jar, file:/C:/Users/Crest/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar, file:/C:/Users/Crest/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar, file:/C:/Users/Crest/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.jar, file:/C:/Users/Crest/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar, file:/C:/Users/Crest/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar, file:/C:/Users/Crest/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar, file:/C:/Users/Crest/.m2/repository/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar, file:/C:/Users/Crest/.m2/repository/org/hibernate/hibernate-entitymanager/4.3.11.Final/hibernate-entitymanager-4.3.11.Final.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot-starter/1.3.5.RELEASE/spring-boot-starter-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot/1.3.5.RELEASE/spring-boot-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.3.5.RELEASE/spring-boot-autoconfigure-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.3.5.RELEASE/spring-boot-starter-logging-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar, file:/C:/Users/Crest/.m2/repository/org/slf4j/jul-to-slf4j/1.7.21/jul-to-slf4j-1.7.21.jar, file:/C:/Users/Crest/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.21/log4j-over-slf4j-1.7.21.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/spring-core/4.2.6.RELEASE/spring-core-4.2.6.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.3.5.RELEASE/spring-boot-starter-web-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.3.5.RELEASE/spring-boot-starter-tomcat-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.0.33/tomcat-embed-core-8.0.33.jar, file:/C:/Users/Crest/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.0.33/tomcat-embed-el-8.0.33.jar, file:/C:/Users/Crest/.m2/repository/org/apache/tomcat/embed/tomcat-embed-logging-juli/8.0.33/tomcat-embed-logging-juli-8.0.33.jar, file:/C:/Users/Crest/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.0.33/tomcat-embed-websocket-8.0.33.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot-starter-validation/1.3.5.RELEASE/spring-boot-starter-validation-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/hibernate/hibernate-validator/5.2.4.Final/hibernate-validator-5.2.4.Final.jar, file:/C:/Users/Crest/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.6.6/jackson-databind-2.6.6.jar, file:/C:/Users/Crest/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.6.6/jackson-annotations-2.6.6.jar, file:/C:/Users/Crest/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.6.6/jackson-core-2.6.6.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/spring-webmvc/4.2.6.RELEASE/spring-webmvc-4.2.6.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/1.3.5.RELEASE/spring-boot-starter-actuator-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot-actuator/1.3.5.RELEASE/spring-boot-actuator-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/boot/spring-boot-starter-test/1.3.5.RELEASE/spring-boot-starter-test-1.3.5.RELEASE.jar, file:/C:/Users/Crest/.m2/repository/junit/junit/4.12/junit-4.12.jar, file:/C:/Users/Crest/.m2/repository/org/mockito/mockito-core/1.10.19/mockito-core-1.10.19.jar, file:/C:/Users/Crest/.m2/repository/org/objenesis/objenesis/2.1/objenesis-2.1.jar, file:/C:/Users/Crest/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar, file:/C:/Users/Crest/.m2/repository/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar, file:/C:/Users/Crest/.m2/repository/org/springframework/spring-test/4.2.6.RELEASE/spring-test-4.2.6.RELEASE.jar]
那么我在这里缺少什么?提前谢谢。
我也在SO上引用了一些相同的主题,如:No Dialect mapping for JDBC type
但没有我的错误代码与提到的所有其他错误不同。
修改
#server.name=logs
#application.log.path=${user.dir}
#service.name=@project.name@
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=true
spring.database.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/rootdb
spring.datasource.username=postgres
spring.datasource.password=123
spring.jpa.hibernate.ddl-auto=create
server.port=7002
logging.level.org.hibernate.SQL=DEBUG
#spring.datasource.type=org.apache.commons.dbcp2.BasicDataSource
spring.jpa.database-platform= postgres
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect
的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.toyota.aftersales.tten</groupId>
<artifactId>tten-common</artifactId>
<version>v0.0.1</version>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<!--API Documentation -->
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<!-- Used in Internal compiler path for testing with MockMvc -->
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<!--User interface for API Documentation -->
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.0.Final</version>
</dependency>
<dependency>
<!-- Dozer for map classes -->
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.5.1</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
</dependencies>
</project>
依赖列表:
[INFO] The following files have been resolved:
[INFO] io.springfox:springfox-spi:jar:2.7.0:compile
[INFO] io.springfox:springfox-core:jar:2.7.0:compile
[INFO] org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
[INFO] aopalliance:aopalliance:jar:1.0:compile
[INFO] net.bytebuddy:byte-buddy:jar:1.6.14:compile
[INFO] io.springfox:springfox-swagger-ui:jar:2.7.0:compile
[INFO] org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] javax.validation:validation-api:jar:2.0.0.Final:compile
[INFO] org.springframework:spring-aop:jar:4.0.9.RELEASE:compile
[INFO] antlr:antlr:jar:2.7.7:compile
[INFO] org.springframework:spring-expression:jar:4.0.9.RELEASE:compile
[INFO] org.springframework:spring-jdbc:jar:5.0.4.RELEASE:compile
[INFO] io.springfox:springfox-schema:jar:2.7.0:compile
[INFO] ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] io.springfox:springfox-swagger-common:jar:2.7.0:compile
[INFO] asm:asm:jar:3.3.1:compile
[INFO] org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO] org.springframework.boot:spring-boot-autoconfigure:jar:2.0.0.RELEASE:compile
[INFO] commons-logging:commons-logging:jar:1.2:compile
[INFO] org.springframework.data:spring-data-jpa:jar:2.0.5.RELEASE:compile
[INFO] net.minidev:asm:jar:1.0.2:compile
[INFO] net.sf.dozer:dozer:jar:5.5.1:compile
[INFO] org.mapstruct:mapstruct:jar:1.1.0.Final:compile
[INFO] dom4j:dom4j:jar:1.6.1:compile
[INFO] org.springframework.data:spring-data-commons:jar:2.0.5.RELEASE:compile
[INFO] org.springframework:spring-context:jar:4.0.9.RELEASE:compile
[INFO] org.springframework.boot:spring-boot:jar:2.0.0.RELEASE:compile
[INFO] org.hibernate:hibernate-core:jar:5.2.14.Final:compile
[INFO] org.springframework.boot:spring-boot-starter-aop:jar:2.0.0.RELEASE:compile
[INFO] org.springframework.boot:spring-boot-starter-jdbc:jar:2.0.0.RELEASE:compile
[INFO] com.fasterxml.jackson.core:jackson-annotations:jar:2.8.5:compile
[INFO] org.apache.commons:commons-lang3:jar:3.2.1:compile
[INFO] org.javassist:javassist:jar:3.22.0-GA:compile
[INFO] org.springframework.boot:spring-boot-starter-data-jpa:jar:2.0.0.RELEASE:compile
[INFO] org.slf4j:slf4j-api:jar:1.7.24:compile
[INFO] org.jboss:jandex:jar:2.0.3.Final:compile
[INFO] commons-collections:commons-collections:jar:3.2.1:compile
[INFO] org.yaml:snakeyaml:jar:1.19:runtime
[INFO] org.springframework:spring-jcl:jar:5.0.1.RELEASE:compile
[INFO] com.zaxxer:HikariCP:jar:2.7.8:compile
[INFO] org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] commons-beanutils:commons-beanutils:jar:1.9.1:compile
[INFO] org.aspectj:aspectjweaver:jar:1.8.13:compile
[INFO] net.minidev:json-smart:jar:2.1.1:compile
[INFO] org.springframework:spring-web:jar:5.0.1.RELEASE:compile
[INFO] ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] org.springframework.boot:spring-boot-starter-logging:jar:2.0.0.RELEASE:compile
[INFO] org.springframework:spring-beans:jar:5.0.1.RELEASE:compile
[INFO] org.springframework:spring-aspects:jar:5.0.4.RELEASE:compile
[INFO] org.springframework:spring-orm:jar:5.0.4.RELEASE:compile
[INFO] io.springfox:springfox-swagger2:jar:2.7.0:compile
[INFO] io.swagger:swagger-annotations:jar:1.5.13:compile
[INFO] org.springframework:spring-core:jar:5.0.1.RELEASE:compile
[INFO] com.google.guava:guava:jar:18.0:compile
[INFO] com.jayway.jsonpath:json-path:jar:2.0.0:compile
[INFO] io.swagger:swagger-models:jar:1.5.13:compile
[INFO] javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] org.slf4j:jcl-over-slf4j:jar:1.7.5:compile
[INFO] org.reflections:reflections:jar:0.9.11:compile
[INFO] com.fasterxml:classmate:jar:1.3.3:compile
[INFO] postgresql:postgresql:jar:9.1-901-1.jdbc4:compile
[INFO] org.springframework.boot:spring-boot-starter:jar:2.0.0.RELEASE:compile
[INFO] org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] io.springfox:springfox-spring-web:jar:2.7.0:compile
[INFO] org.springframework:spring-tx:jar:5.0.4.RELEASE:compile
答案 0 :(得分:0)
添加更多属性,请尝试替换此
spring.jpa.database平台= org.hibernate.dialect.PostgreSQLDialect
到
spring.datasource.type = org.apache.commons.dbcp2.BasicDataSource
spring.jpa.database-platform = postgres spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL9Dialect
<强>被修改强>
spring.jpa.database-platform=postgres
spring.datasource.platform=postgres
spring.jpa.show-sql=true
#spring.database.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/rootdb
spring.datasource.username=postgres
spring.datasource.password=123
spring.jpa.hibernate.ddl-auto=create
server.port=7002
logging.level.org.hibernate.SQL=DEBUG
#spring.datasource.type=org.apache.commons.dbcp2.BasicDataSource
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect