1 pom.xml
1.1 依赖对应功能
<artifactId>spring-boot-autoconfigure</artifactId> <!-- 自动配置的相关依赖,定义starter的时候必须要有 --> <artifactId>spring-boot-configuration-processor</artifactId> <!-- spring默认使用yml中的配置,但有时候要用传统的xml或properties配置,就需要使用spring-boot-configuration-processor了。-->
2 常见问题
Annotation processing is not supported for module cycles.
项目启动报这个Error的原因是moudle循环依赖的问题,就是我依赖了你,同时你也依赖了我,这时候就回产生循环依赖问题
could not execute query
问题:sql语法不正确
原因:sql拼接时写了两个and 连着
解决方案:正确写sql语句
could not extract ResultSet
实体类未加@Id主键注解
error at ::0 formal unbound
N.1.1 确认 JoinPoint类是否导错了包,是import org.aspectj.lang.JoinPoint;
N.1.2 去掉多余参数
Method breakpoints may dramatically slow down debugging
问题:debug起来很慢,run正常启动,debug的时候提示如上
原因:方法上有断点
解决方案:清除所有断点,重新执行即可
JPA Not a managed type
问题:jpa实体类未被扫描到
原因:实体类没有添加@Entity注解
解决方案:添加注解即可
No property xxx found for type xxx
这个单独dao是接口,继承了公共dao层,我又手写了单独dao的save方法,调dao.save方法的时候报错
解决方案:将单独dao的save方法去掉,再次运行问题解决
org.springframework.beans.factory.annotation.Autowired(required=true)
service找不到依赖
source 1.5 中不支持 lambda 表达式
pom.xml修改如下:
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.2</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins>
UnsatisfiedDependencyExceptions:Error creating bean with name 'XXX':unsatisfied dependency ...
1 首先根据测试类,找到调用对应方法,不断溯源(找到四级分类方法,四级分类方法中有报错)
2 解决报错后,依然报这个问题,推测是实现类@Service没写,查看后发现注解也有,
3 再继续想,测试类和实现类不在同一个模块(for save,接口和实现类大都不在同一模块),然后在测试类模块的pom.xml引入实现类所在模块的pom.xml,-->maven-->reload project-->重新跑测试类,问题解决。
其实也可以尝试 mock的方式去做测试
warning no match for this type name:com.xxx.xxx [Xlint:invalidAbsoluteTypeName]
@Around("execution(* com.xxx.xxx.service..*.*(..))")
3 注意事项
3.1 不要随便引入dependency
N 安装windows kafka踩的坑
参考这篇博客操作:
https://www.cnblogs.com/flower1990/p/7466882.html
windows系统下启动kafka CMD报错:输入行太长,语法错误
kafka目录不要建太深,最多三层
windows系统创建生产者报错
WARN [Producer clientId=console-producer] Bootstrap broker localhost:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
解决方案:在server.properties
开启监听:listeners=PLAINTEXT://127.0.0.1:9092
zookeeper cmd运行:Exception in thread "main" java.lang.UnsupportedClassVersionError: xxx/xxx : Unsupported major.minor version 52.0
更换jdk版本为1.8,并且将环境变量也配置成1.8即可
zookeeper cmd运行:Unable to access datadir, exiting abnormally * Unable to create data directory
Unable to access datadir, exiting abnormally
org.apache.zookeeper.server.persistence.FileTxnSnapLog$DatadirException: Unable to create data directory D:javahuancunkafkaapache-zookeeper-3.6.2-binapache-zookeeper-3.6.2-bin mp\version-2
路径问题:配置dataDir=D:\\java\huancun\\kafka\\apache-zookeeper-3.6.2-bin\\apache-zookeeper-3.6.2-bin\\tmp
ZooKeeper audit is disabled.
修改zkServer.cmd为
call %JAVA% "-Dzookeeper.audit.enable=true" "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" "-Dzookeeper.log.file=%ZOO_LOG_FILE%" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%%%p /t /f" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*