我正在制作一个Web项目,在本地完成后,我将其上传到服务器(centos7),但是当我转到主页时,日志将返回此错误。
奇怪的是,在我的笔记本电脑(Mac)上一切正常,但是当我通过服务器打开它时。 spring-boot日志告诉您找不到两个表。所有其他表似乎还可以。和主页确实从db获取数据。从现在起,我无法从Internet找到解决方案。我检查了服务器中的db,两个表都存在。(它们内部目前没有数据。)
@Entity
@Table(name = "orderItem")
@JsonIgnoreProperties({ "handler","hibernateLazyInitializer" })
public class OrderItem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private int id;
@ManyToOne
@JoinColumn(name="pid")
private Product product;
@ManyToOne
@JoinColumn(name="oid")
private Order order;
@OneToOne
@JoinColumn(name="uid")
private User user;
@OneToOne
@JoinColumn(name="sid")
private User seller;
public List<Request> getRequests() {
return requests;
}
public void setRequests(List<Request> requests) {
this.requests = requests;
}
@Transient
private List<Request> requests;
private int status;
private int price;
private Date createDate;
private int way;
private int number;
///////////////////////////////////////// + ---------------------- + | Tables_in_gogogo + ---------------------- + |地址| |类别| |聊天消息| | order_ | |订单| |产品| |产品图片| |物业| |属性值| |要求| |评论| |用户| |用户图片| |愿望清单| + ---------------------- + ////////////////////////////
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/gogogo?
useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDate
timeCode=false&serverTimezone=UTC&useSSL=false
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto = none
spring.jpa.hibernate.naming.physicalstrategy=
org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
///////////////////////////////////////////////// //////////
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:499)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:477)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:56)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
... 65 more
原因:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:表'gogogo.orderItem'不存在 在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)处 在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 在java.lang.reflect.Constructor.newInstance(Constructor.java:423) 在com.mysql.jdbc.Util.handleNewInstance(Util.java:425) 在com.mysql.jdbc.Util.getInstance(Util.java:408) 在com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943) 在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) 在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909) 在com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527) 在com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680) 在com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2487) 在com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858) 在com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1966) 在sun.reflect.GeneratedMethodAccessor102.invoke(未知来源) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498) 在org.apache.tomcat.jdbc.pool.StatementFacade $ StatementProxy.invoke(StatementFacade.java:114) 在com.sun.proxy。$ Proxy130.executeQuery(未知来源) 在org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70) ...还有96
我在此错误上浪费了很多时间。
答案 0 :(得分:0)
表名在MySQL中区分大小写。在实体类中将表名称更正为“ orderitem”,然后重试。与“聊天”表相同。