发表于: 2018-06-09 23:58:56

2 910


今天完成的事情:

1.怎么样能让Maven跳过JUnit?

办法一:

当 Surefire 插件到达 test 目标的时候,如果 maven.test.skip 设置为 true ,它就会跳过单元测试。 

办法二:

在pom.xml中build添加plugin元素

<project>

  [...]

  <build>

    <plugins>

      <plugin>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-surefire-plugin</artifactId>

        <configuration>

          <skip>true</skip>

        </configuration>

      </plugin>

    </plugins>

  </build>

  [...]

</project>

想一想:为什么要跳过Junit测试?

百度了一下,发现没有相关原因,想想也是,有时候因为环境的限制没有时间写测试代码,或则可能本地不兼容,需要布置到特定的服务器上才能正确执行。

2.修改UserDao.xml文件

<insert id="insert" parameterType="com.system.model.User">

         <selectKey resultType="int" order="AFTER" keyProperty="id">

             select LAST_INSERT_ID()

         </selectKey>

   INSERT INTO student VALUES (null,#{name},#{QQ},#{train_major},#{admiss_time},

        #{graduate_school},#{online_number},#{Daily_link},#{oath},#{coaching_senior},

        #{where_know},#{create_at},#{update_at})

</insert>

知识点:

SELECT LAST_INSERT_ID():得到刚 insert 进去记录的主键值,只适用与自增主键

keyProperty:将查询到主键值设置到 parameterType 指定的对象的那个属性

SelectKey在Mybatis中是为了解决Insert数据时不支持主键自动生成的问题,他可以很随意的设置生成主键的方式。

resultType:指定 SELECTLAST_INSERT_ID() 的结果类型

链接:https://blog.csdn.net/czd3355/article/details/71302441

测试插入1000条数据测试

所需的时间15620ms

所需时间18882ms

所需的时间19454ms

平均时间:17985ms

明天计划的事情:

修改UserDao.xml文件

添加事务,思考使用List把数据装成集合进行插入

list部分代码改了一部分,还没改好

遇到的问题:

我想跳过Junit的原因对吗?(愿意回答的请私信我哈,感谢)

收获:

1.了解到跳过Junit测试的方法(加载一个插件)

2.今天室友借着酒劲说出了藏在内心的话,也说了对我的看法。这很重要,我常常想知道在别人眼中我到底是什么样子的?是褒是贬?是一身臭毛病还是不错的朋友?

3.修改了UserDao.xml


返回列表 返回列表
评论

    分享到