java项目Error汇总

1、jdk11连接数据库出现无法获取连接的错误

解决方法:
      换更高版本的数据库驱动
      
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.26</version>
        </dependency>

2、jdk11查询数据库,显示持久层空指针异常

解决方法:选用更高版本的mybatis

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.0</version>
        </dependency>

3、新建的module在maven中显示是灰色的

解决办法:
     在idea中点击File>settings,搜索maven,点击ignored Files,可以看到灰色的模块处于选中状态,
去掉选中状态点击保存即可正常使用。

在这里插入图片描述
4、不再支持源选项 5,请使用 6 或更高版本

//解决方法:
   <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>11</java.version>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>

5、如何在一个module中引入其他的module

   <dependencies>
         <dependency>
             <groupId>com.united-imaging</groupId>
             <artifactId>Platform_Common</artifactId>
             <version>1.0-SNAPSHOT</version>
         </dependency>
     </dependencies>

6、java.lang.IllegalStateException: Service id not legal hostname (platform_server)

解决方法:
        spring.application.name=platform-consumer  //名称不能带下划线
7、如何把前端传过来的json对象转化为实体对象

```java
解决方法:
   在参数前加@RequestBody
 public String  createUser(@RequestBody UserInfo userInfo)

8、如何配插件

解决方法:
      <build>
       <plugins>
           <plugin>
           </plugin>
       </plugins>
   </build> 

9、idel中打开命令窗口

解决方法:Alt+F12

10、The bean ‘platform-server.FeignClientSpecification’, defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.

解决方法:
   升级Spring Boot 2.1.0 Spring Cloud Greenwich.M1  版本后,
   在2Feign接口类内定义相同的名字,  @FeignClient(name = 相同的名字
   就会出现报错,在之前的版本不会提示报错

11、generatorConfig.xml的头文件http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd标红

解决方案:
        左边有红色小灯泡,点击Fetch external resource即可解决

12、Correct the classpath of your application so that it contains a single, compatible version of com.google.common.cache.CacheBuilder

解决方法:jar包冲突,删除冲突的jar包

13、使用feign进行远程调用,如果返回实体,该实体必须有空构造函数

14、前端传过来的Json,后端解析成对象的时候,有的属性,解析为空

解决方法:
       对一下,前后端的变量名是否一致,大小写是否一致

15、springboot2.0以上版本

//springboot2.0以上数据库驱动要加上cj
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

//springboot2.0以上数据库地址要加上时区
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC


15、编译时配置文件无法加载(可以直接把配置文件复制到target目录下)
在这里插入图片描述
16、执行insert语句返回主键值,在xml文件中如何配置

 <insert id="insertDashBoardSelective" parameterType="com.unitedimaging.pojo.DashBoard"  useGeneratedKeys="true" keyProperty="id">

//keyProperty:实体的属性名

17、springboot项目,A模块引入B模块,那么要在A模块的启动类上配置包扫描,如果不配,B模块的配置无法生效,因为A的启动类默认只扫描A模块的配置`

@SpringBootApplication
@ComponentScan("com.bbz")//在A模块的启动类上加上这个注解  
public class EduApplication {

    public static void main(String[] args) {
        SpringApplication.run(EduApplication.class, args);
    }
}

18、执行sql一直报错,但是检查sql,sql是没有问题的,可能是数据库的字段是关键字导致的

19使用swagger进行测试时,出现json转化错误,可能是逗号使用的中文逗号

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值