在用maven进行打包的时候出现错误
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project yuyun: There are test failures.
Please refer to E:\IdeaProjects\yuyun\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.
在其他地方搜到很多,都是跳过Test打包
然后我在命令行用命令mvn clean package
打包,发现在测试类出现错误
之后我去查看测试类的代码
package com.example.yuyun;
import com.example.yuyun.model.Users;
import com.example.yuyun.security.utils.SecurityUtils;
import com.example.yuyun.service.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class YuyunApplicationTests {
@Autowired
UserService userService;
@Test
void contextLoads() {
Users users=userService.getUser("91");
for (int i=0;i<100;i++){
users.setUserName("用户1"+i);
users.setUserPwd(SecurityUtils.encodePassword(String.valueOf(458246+i)));
Boolean u=userService.insertUsers(users);
}
}
}
将里面的功能代码注释掉,重新打包就没有问题了