SpringBoot

启动类(有@SpringBootApplication注解的类)一定要放在根包下

一般java source下会放置一个包,所有类都在这个包下。这样扫描的类都在这个包下

格式化插件

        <plugin>
            <groupId>com.coveo</groupId>
            <artifactId>fmt-maven-plugin</artifactId>
            <version>2.5.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>format</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Mybatis

要让mybatis扫描指定包下的mapper文件


@org.mybatis.spring.annotation.MapperScan(
    value = {
      "com.xxx.ad.data.bi.analysis.service.dao.scene.task.mapper",
      "com.xxx.ad.data.bi.analysis.service.dao.self.service.mapper",
      "com.xxx.ad.data.bi.analysis.service.dao.correlation.task.mapper",
      "com.xxx.ad.data.bi.analysis.service.dao.feedback.mapper",
      "com.xxx.ad.data.bi.analysis.service.dao.predict.mapper"
    })

application.yml中配置

则resources打包后,会变成classpath下的文件。所以寻找配置xml的时候去这个路径找


mybatis:
  typeHandlersPackage: "com.xxx.ad.data.bi.analysis.service.component"
  mapper-locations: classpath:mybatis_mapper/*.xml
  configuration:
    map-underscore-to-camel-case: true


部分标签用法


<update id="updateExecutionExtraDataByTaskExecutionId">
  UPDATE compass_analysis_scene_task_execution
  <set>
    <if test="entity.comparisonType != null">
      comparison_type = #{entity.comparisonType},
    </if>
    <if test="entity.subscriptionConfigJson != null">
      subscription_config_json = #{entity.subscriptionConfigJson},
    </if>
    <if test="entity.extraConfigJson != null">
      extra_config_json = #{entity.extraConfigJson},
    </if>
    <if test="entity.abnormalRuleJson != null">
      abnormal_rule_json = #{entity.abnormalRuleJson},
    </if>
    <if test="entity.abnormalResultJson != null">
      abnormal_result_json = #{entity.abnormalResultJson},
    </if>
  </set>
  WHERE id = #{entity.id}
</update>


<select id="getTreeSimpleMetaList" resultType="com.xxx.ad.data.bi.analysis.service.dto.scene.tree.response.TreeSimpleMeta">
    SELECT c.tree_id,
        version,
        root_metric_id,
        creator,
        modify_user,
        UNIX_TIMESTAMP(first_create_time) create_time,
        UNIX_TIMESTAMP(modify_time) modify_time,
        task_count,
        tree_name,
        tree_description,
        available_versions,
        project_id
    FROM
        (SELECT *
          FROM compass_analysis_scene_tree a
        INNER JOIN
        (SELECT max(id)max_id,
        group_concat(VERSION separator ',')available_versions,
        min(create_time) first_create_time
        FROM compass_analysis_scene_tree
        WHERE is_del=0 AND is_preview=0
        GROUP BY tree_id)b ON a.id=b.max_id
        AND is_del=0) c
    LEFT JOIN
        (SELECT tree_id,
          COUNT(1) task_count
        FROM compass_analysis_scene_task
        WHERE is_del=0
        GROUP BY tree_id)d
    ON c.tree_id=d.tree_id
  <where>
      is_del=0
      <if test="treeName != null">
          AND tree_name LIKE CONCAT('%', #{treeName}, '%')
      </if>
      <if test="userName != null">
          AND (creator = #{userName} OR modify_user = #{userName})
      </if>
      <if test="creator != null">
          AND creator = #{creator}
      </if>
      <if test="modifyUser != null">
          AND modify_user = #{modifyUser}
      </if>
      <if test="createTimeBegin != null">
          AND create_time > FROM_UNIXTIME(#{createTimeBegin})
      </if>
      <if test="createTimeEnd != null">
          AND create_time < FROM_UNIXTIME(#{createTimeEnd})
      </if>
      <if test="treeIds != null">
          AND c.tree_id IN
          <foreach collection="treeIds" item="item" index="index" open="(" separator="," close=")">
              #{item}
          </foreach>
      </if>
      <if test="rootMetricIds != null">
          AND root_metric_id IN
          <foreach collection="rootMetricIds" item="item" index="index" open="(" separator="," close=")">
              #{item}
          </foreach>
      </if>
      <if test="keyWord != null">
          AND (c.tree_id LIKE CONCAT('%', #{keyWord}, '%')
          OR tree_name LIKE CONCAT('%', #{keyWord}, '%'))
      </if>
      <if test="projectIds != null">
          AND project_id IN
          <foreach collection="projectIds" item="item" index="index" open="(" separator="," close=")">
              #{item}
          </foreach>
      </if>
      <if test="businessLineIds != null">
          AND project_id IN
          <foreach collection="businessLineIds" item="item" index="index" open="(" separator="," close=")">
              #{item}
          </foreach>
      </if>
  </where>
  ORDER BY ${orderBy} ${orderType}
</select>

全部评论

相关推荐

码农索隆:想看offer细节
点赞 评论 收藏
分享
认真搞学习:这么良心的老板真少见
点赞 评论 收藏
分享
榕城小榕树:1200单休,我去干点啥别的不好
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务