我想創建一個簡單的春季啓動應用程序,它將連接到HSQLDB並與用戶表一起工作,但是我在嘗試啓動時遇到了這個問題。春季開機無法啓動HSQLDB
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
與整個控制檯輸出這裏: http://pastebin.com/7HminjFL
我的文件頃:
Application.java
@Configuration
@SpringBootApplication
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = "hello")
@ComponentScan(basePackages = "hello")
@PropertySource({"classpath:application.properties"})
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Account.java
@Entity
@Table(name = "User", schema = "PUBLIC")
public class Account implements Serializable {
@Id
private Long id;
@Column(name = "Login", nullable = false)
private String login;
@Column(name = "Password", nullable = false)
private String password;
protected Account() {
// no-args constructor required by JPA spec
// this one is protected since it shouldn't be used directly
}
public Account(String login, String password) {
this.login = login;
this.password = password;
}
public String getLogin() {
return login;
}
public String getPassword() {
return password;
}
public void setLogin(String login) {
this.login = login;
return;
}
public void setPassword(String password) {
this.password = password;
return;
}
}
AccountRepository.java
public interface AccountRepository extends JpaRepository<Account, Long> {
Long countByLogin(String login);
}
application.properties
spring.datasource.url=jdbc:hsqldb:file:C:\DB\TestDB
spring.datasource.username=SA
spring.datasource.password=
spring.datasource.driver-class-name=org.hsqldb.jdbcDriver
您正在使用Spring Boot,然後使用Spring引導,您正在努力不去嘗試。將'Application'類移動到'hello'包中,移除所有註釋,但刪除'SpringBootApplication'註釋。然後再次啓動應用程序,如果仍然失敗,請將堆棧跟蹤添加到您的問題中。 –
我已經刪除了註釋(我只在嘗試解決此問題時添加了該註釋),同樣的錯誤仍然存在,我將整個控制檯輸出粘貼到pastebin,因爲它很大。 – Noozen