这种Jpa的错误查找错误出处,错误详情如下

ERROR [12:01:12.102] [1da1d72f575b4f95af5e0cdde8b114e1] [192847] [1] [] [100] [2.28.1] [o.h.e.jdbc.spi.SqlExceptionHelper – logExceptions – 142] – Table ‘tp.video’ doesn’t exist
ERROR [12:01:12.107] [1da1d72f575b4f95af5e0cdde8b114e1] [192847] [1] [] [100] [2.28.1] [c.y.m.c.b.util.RestBusinessTemplate – doExecuteWithoutTransaction – 79] – execute error x
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet

重点:

ERROR [12:01:12.102] [1da1d72f575b4f95af5e0cdde8b114e1] [192847] [1] [] [100] [2.28.1] [o.h.e.jdbc.spi.SqlExceptionHelper – logExceptions – 142] – Table ‘tp.video’ doesn’t exist

有的时候是字段对不上,有的时候是表不存在,直接创建即可

错误完整信息

WARN [21:31:08.169] [] [o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - refresh - 559] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rewardIssuanceHandler': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminManager': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'esUserDAO' defined in cn.yizhoucp.tianai.api.project.dal.es.dao.EsUserDAO defined in @EnableElasticsearchRepositories declared on TianaiServiceApplication: Cannot resolve reference to bean 'elasticsearchTemplate' while setting bean property 'elasticsearchOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticsearchTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataConfiguration$RestClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate]: Factory method 'elasticsearchTemplate' threw exception; nested exception is java.lang.NoSuchFieldError: LATEST
DEBUG [21:31:08.186] [] [com.aliyun.oss - run - 73] - Shutting down reaper thread.
ERROR [21:31:08.215] [] [o.s.boot.SpringApplication - reportFailure - 837] - Application run failed

刚开始以为是bean加载不了,看下Idea语法也没有报错,网上找了一波 Spring boot2.x + Elasticsearch7.x 才想起引入了分词依赖

<dependency>
    <groupId>com.jianggujin</groupId>
    <artifactId>IKAnalyzer-lucene</artifactId>
    <version>4.1.0</version>
</dependency>

可能有比较老的jar包冲突了。查了一下文档,发现lucene-core未引入,果断引入解决问题
<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-core</artifactId>
    <version>8.8.1</version>
</dependency>

Could not transfer artifact junit:junit:pom:4.13 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/junit/junit/4.13/junit-4.13.pom

Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.5.6 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.5.6/spring-boot-starter-parent-2.5.6.pom

错误原因未 开启了 charles 无法下载包。关闭charles就可以了

稀疏函数实现

package array;

public class sparseArray {
public static void main(String[] args) {
sparse();
}

public static void sparse() {
int length = 11;
int[][] array1 = new int[length][length];
array1[2][3] = 1;
array1[3][4] = 2;
System.out.println("原始数组");
prints(array1);

System.out.println("转为稀疏数组");
int sum = 0;//系数数组的个数
for (int i = 0; i < array1.length; i++) { for (int j = 0; j < array1.length; j++) { if (array1[i][j] != 0) { sum += 1; } } } int[][] array2 = new int[sum + 1][3]; array2[0][0] = length; array2[0][1] = length; array2[0][2] = sum; //赋值稀疏数组 int count = 0; for (int i = 0; i < array1.length; i++) { for (int j = 0; j < array1[i].length; j++) { if (array1[i][j] != 0) { count++; array2[count][0] = i; array2[count][1] = j; array2[count][2] = array1[i][j]; } } } prints(array2); System.out.println("还原稀疏数组"); int[][] array3 = new int[length][length]; for (int i = 1; i < array2.length; i++) { array3[array2[i][0]][array2[i][1]] = array2[i][2]; } prints(array3); } public static void prints(int[][] array) { for (int[] ints : array) { for (int anInt : ints) { System.out.print(anInt + "\t"); } System.out.println(); } } }