In the process of learning "spring boot", because the original book author inevitably have some missing places, or system, software version inconsistency, framework updates and other factors, the full installation of the source page in the book can not achieve the normal start of the project
In chapter 8.2, when the JPA support for Oracle is demonstrated, the following code is set in the configuration file, which normally should support the database to automatically create the sequence and table, but the actual startup error "ORA-00942: Table or view does not exist"
Spring.datasource.driverclassname=Oracle.jdbc.OracleDriverspring.datasource.url=jdbc\:oracle\:thin\:@ localhost\:1521\:xespring.datasource.username=XXXXX (replace here with your database user name) Spring.datasource.password =XXXXX (please replace the password for your database username here) #1spring.jpa.hibernate.ddl-auto=update#2 Spring.jpa.show-sql=true#3spring.jackson.serialization.indent-output=True
Data.sql to insert the data:
Insert into person (id,name,age,address) VALUES (hibernate_sequence.nextval,xxx ', 32, ' Hefei '); insert into person (id,name, age,address) VALUES (hibernate_sequence.nextval, ' xx ', 31, ' Beijing '); insert into person (id,name,age,address) VALUES ( Hibernate_sequence.nextval,' yy ', 30, ' Shanghai '); insert into person (id,name,age,address) VALUES (hibernate_ Sequence.nextval,' ZZ ', 29, ' Nanjing '); insert into person (id,name,age,address) VALUES (hibernate_sequence.nextval ,' AA ', 28, ' Wuhan '); insert into person (id,name,age,address) VALUES (hibernate_sequence.nextval,' BB ', 27, ' Hefei ');
Workaround:
Under Src/main/resources, create a new schema.sql with the following content:
Create sequence hibernate_sequence increment by 1 start with 1 maxvalue 999999999; CREATE TABLE person (ID number (5) PRIMARY key,name VARCHAR2 (a) Not null,age number (5), Address VARCHAR2 (15 ) tablespace your_table_space (replace the table space for the database account you're logged into, and if you don't have a table space, you'll need to add a row to create a table-space SQL at the beginning of this code)
The table space can be viewed here:
If the project starts to finish, the access page appears "whitelabel Error page", adjust the file structure of the project code:
com + Example + myproject + Application.java | + - domain| + - Customer.java| + - Customerrepository.java| + - Service| + - Customerservice.java| + - Web+-Customercontroller.java
The solution for this article is fully reference to the following links:
http://blog.csdn.net/lvyuan1234/article/details/65631176
Spring Boot 8.2 does not start properly when learning, "ORA-00942: Table or view does not exist"