(1)可能没加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
(2)可能maven生命周期test失败,需要跳过可加
<plugin><!--编译跳过测试文件检查的生命周期-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path ‘xxxx’
Caused by: java.lang.TypeNotPresentException: Type org.springframework.kafka.listener.RecordInterceptor not present
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117) ~[na:1.8.0_311]
org.springframework.core.MethodParameter.getGenericParameterType(MethodParameter.java:513) ~[spring-core-5.2.14.RELEASE.jar:5.2.14.RELEASE]
原因:kafka需要依赖这个spring-core-5.2.14.RELEASE.jar:5.2.14.RELEASE,所以要注spring-kafka,spring-boot-starter-parent,kafka-clients三者版本
比如:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.4.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.4.1</version>
</dependency>
Error injecting constructor, java.lang.NoSuchMethodError: org.apache.maven.model.validation
解决:替换成maven3.6.3就好了
The POM for com.dzh:grpc-lib:jar:1.0-SNAPSHOT is missing, no dependency information available
Failed to execute goal on project grpc-server: Could not resolve dependencies for project com.dzh:grpc-server:jar:1.0-SNAPSHOT: Failure to find com.dzh:grpc-lib:jar:1.0-SNAPSHOT in https://maven.aliyun.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of snapshots has elapsed or updates are forced
Could not find artifact com.dzh:grpc-lib:pom:1.0-SNAPSHOT in snapshots (https://maven.aliyun.com/nexus/content/groups/public)
意思很明显,就是依赖没找到。去仓库发现就这么几个玩意,并没有对应的jar包
所以我们删除仓库的该包,重新对该module进行install一下
我建议就是,在maven仓库把该项目的依赖都删除,重新在父工程install
问题: 今天使用了一个实体类去映射数据库报这个错
Cannot determine value type from string “xxx”
数据库表字段类型与Java类里面都成员属性类型不一致,然后检查MyBatis中xml各自配置,感觉都没问题。
原因: 是在Java类中使用了Lombok的注解@Builder和@Data,导致JavaBean中没有无参构造器。
解决: 只需再添加两个Lombok注解@NoArgsConstructor和@AllArgsConstructor即可。
返回的是一个值,但如果数据库查出了多条数据就会报这个错误:
Expected one result (or null) to be returned by selectOne(), but found: 2
Mybatis-plus的this.getOne()方法也可能报这个错
解决:只需要保证数据库只查出一条数据即可。
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field “id”
原因是我的数据库里的json有id这个k-v,但我的实体没有这个id属性
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `com.hnxh.system.domain.vo.FileInfoVO` from Array value (token `JsonToken.START_ARRAY`) at [Source: (PushbackInputStream); line: 1, column: 1504] (through reference chain: com.hnxh.business.domain.dto.employee.EmployeeDimissionDTO["relieveFile"])原因是传递的json中 relieveFile:[],而我后端实体中 private FileInfoVO relieveFile;
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
url后加:allowPublicKeyRetrieval=true
允许客户端从服务器获取公钥
Could not create connection to database server. Attempted reconnect 3 times. Giving up.
原因是我的mysql是8.0的,而数据库驱动版本太低,所以改为
mysql
mysql-connector-java
8.0.20
java.sql.SQLException: The server time zone value ‘�й���ʱ��’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the ‘serverTimezone’ configuration property) to use a more specifc time zone value if you want to utilize time zone support.
url后加serverTimezone=GMT%2B8
时区问题
javax.net.ssl.SSLException
MESSAGE: closing inbound before receiving peer’s close_notify
useSSL=false
出现这种情况可能是依赖版本冲突
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org/apache/poi/common/Duplicatable
很明显,poi依赖重复了,可能导入了两种底层是poi的依赖
To allow executing this migration, set -outOfOrder=true.
不小心删除了中间脚本的数据,那么如果设置了有序迁移,就会报错
所以设置为无序迁移,out-of-order默认为false
flyway.out-of-order: true
A granted authority textual representation is required
原因是SimpleGrantedAuthority的构造方法,有断言,role不能为空:
Assert.hasText(role, “A granted authority textual representation is required”);
需要导入依赖:
<!-- QueryDSL 依赖 -->
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-core</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
</dependency>
导入插件:
<build>
<plugins>
<!-- QueryDSL 编译插件 -->
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
然后对实体模块重新package
试试重新clean、package
待续。。。