springboot项目中,项目打包时,跳过Test类

项目场景:

springboot项目进行打包时,发现执行了@SpringBootTest类里面的方法

问题描述

项目里面有测试方法,但是没有料到的是,进行打包时,又执行了一遍,导致我数据重复了

@SpringBootTest
public class EmpServiceTest {

	@Autowired
    private EmpServiceMapper empServiceMapper;

    @Test
    public void testInsert(){
        Emp emp = new Emp ();
        emp.seName("姓名");

        boolean result = empServiceMapper.save(emp);
    }
}

原因分析:

解决方案:

pom.xml

<build>
        <!--定义Maven构建过程中使用的插件列表。-->
        <plugins>
            <!-- 添加 Maven 插件来跳过测试 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

相关推荐

  1. springboot项目项目打包Test

    2024-07-22 08:32:02       19 阅读
  2. springboot项目启动打印全部接口方法

    2024-07-22 08:32:02       31 阅读
  3. SpringBoot项目快速打印controller的URL

    2024-07-22 08:32:02       34 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-22 08:32:02       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-22 08:32:02       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-22 08:32:02       45 阅读
  4. Python语言-面向对象

    2024-07-22 08:32:02       55 阅读

热门阅读

  1. 【【深入浅出FPGA内部资源CLB的解析】】

    2024-07-22 08:32:02       17 阅读
  2. MySQL8的备份方案——增量备份(CentOS)

    2024-07-22 08:32:02       15 阅读
  3. T-SQL编程基础

    2024-07-22 08:32:02       19 阅读
  4. B - Array Craft(cf960)

    2024-07-22 08:32:02       15 阅读
  5. Rust编程-模式匹配

    2024-07-22 08:32:02       19 阅读
  6. 软件测试面试

    2024-07-22 08:32:02       16 阅读
  7. Vbox虚拟机+Ubuntu motest测试drm

    2024-07-22 08:32:02       21 阅读