第一次实战springboot遇到的那些坑
第一次实战springboot遇到的那些坑
记录一下我第一次实战springboot遇到的那些问题。
Maven编译报错
Maven编译报错:Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project springboot-sugon-3: There are test failures.
Please refer to D:\Java_study\springboot\springboot-sugon-3\target\surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.**
解决方案:在pom.xml 中加入以下代码:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
接口
postman报错:org.apache.ibatis.binding.BindingException: Mapper method 'com… has an unsupported return type
解决方案:mapper文件中的update,delete,insert语句是不需要设置返回类型的,它们都是默认返回一个int,应该把接口方法改写为:
void insertPerson(@Param("person")Person person);
或者:
Integer insertPerson(@Param("person")Person person);
奇怪的问题:Mybatis里陌生的IP?
这次遇到了个让人哭笑不得的人造bug,那就是application.properties 文件里的mysq密码输入错误。但是,这个错误的报错信息却很让人迷惑。

就是这个奇怪的IP,让我和学长们对于如何改错产生了疑惑。在好一阵折腾之后,总算想起是mysql密码输入错误!在修改后便没有错误了。但是我们还是对于这个奇怪的IP感到疑惑,经过工具查询,惊讶地发现这个IP的地理位置竟然是我的学校!!看来这个ip应该是我连接的路由器的ip了哈。挺有趣的报错,在这里记录一下。
Postman测试:“status”: 415, “error”: “Unsupported Media Type”
我这里代码其实没有问题,只要把postman的选项换成json即可。

