1 错误: 找不到或无法加载主类
可能的问题:没有成功编译
解决办法:
-
查看输出目录是否设置,在IDEA中正确设置项目编译输出目录。 File -> Project Structure ->
Project
-> Modules -> path -> Inherit project compile output path -
在Build中从新编译
2 在命令行运行Java程序
对于有包的java程序,执行的时候要在包路径的上级路径,使用带有包路径的全限定名来执行。
3 使用Junit时的错误
3.1 Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
解决:引入
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-nop -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.30</version>
<scope>test</scope>
</dependency>
4 错误记录
日期: 2020 年1月15日
错误原因 :接口不能实例化,我却把它作为Spring 的Bean,导致依赖注入始终不成功。