框架-day-58

【数据分享】1985-2023年30米CLCD土地覆盖栅格数据分享 总的来说,CLCD 反映了中国快速的城市化进程和一系列生态工程,揭示了气候变化条件下人为对 LC的影响,其在全球变化研究中具有潜在应用价值。最后,通过目视解译的独立样本和第三方测试样本评估CLCD的准确性。特别地,该研究将CLCD产品与目前最先进的30m专题产品包括不透水表面积(ISA)、地表水和森林进行比对,以综合评估CLCD的质量(以下为技术流程图)。数据分类:分为九类用地,该数据包括9种用地类型,分别为:农田、森林、灌木、草原、水域、冰雪、裸地、不透水面、湿地。数据格式:.tif格式。 阅读详情

2021.12.15    

mybatis

配置属性

properties(属性)

property

settings(全局配置参数)

setting

typeAliases(类型别名)

typeAliase

package

typeHandlers(类型处理器)

objectFactory(对象工厂)

plugins(插件)

environments(环境集合属性对象)

environment(环境子属性对象)

transactionManager(事务管理)

dataSource(数据源)

mappers(映射器)

mapper

package

① Properties属性

在使用 properties 标签配置时,我们可以采用两种方式指定属性配置。

第一种:

properties>

property name="jdbc.driver" value="com.mysql.jdbc.Driver"/>

property name="jdbc.url" value="jdbc:mysql://localhost:3306/test"/>

property name="jdbc.username" value="root"/>

property name="jdbc.password" value="root"/>

properties>

第二种:

在classpath下创建db.properties文件

jdbc.driver=com.mysql.jdbc.Driver

jdbc.url=jdbc:mysql://localhost:3306/test 

jdbc.username=root

jdbc.password=root

 

properties  url=  file:///D:/workspace/day02_test/src/db.properties">properties>

此时我们的 dataSource 标签就变成了引用上面的配置

dataSource type="POOLED">

property name="driver" value="${jdbc.driver}"/>

property name="url" value="${jdbc.url}"/>

property name="username" value="${jdbc.username}"/>

property name="password" value="${jdbc.password}"/>

dataSource>

 

② typeAliases属性

在前面我们讲的 Mybatis 支持的默认别名,我们也可以采用自定义别名方式来开发

在 mybatis-config.xml 中配置:

typeAliases>

typeAlias alias="user" type="com.tledu.zrz.pojo.User"/>

package name="com.tledu.zrz.pojo"/>

package name="其它包"/>

typeAliases>

③ Mappers属性

Mappers使我们所说的映射器,用于通过mybatis配置文件去找到对应的mapper文件

有三种用法

④Resources

使用相对于类路径的资源

如:

⑤class

使用 mapper 接口类路径

如:

注意:此种方法要求 mapper 接口名称和 mapper 映射文件名称相同,且放在同一个目录中。

⑥Package

注册指定包下的所有 mapper 接口

如:

注意:此种方法要求 mapper 接口名称和 mapper 映射文件名称相同,且放在同一个目录中。


2.Mapper.xml属性

1.#和$区别

#{}表示一个占位符号

通过#{}可以实现 preparedStatement 向占位符中设置值,自动进行 java 类型和 jdbc 类型转换,

#{}可以有效防止 sql 注入。

举例:select * from user where username = ' ' or 1=1 # and passord=''

#{}可以接收简单类型值或 pojo 属性值。 如果 parameterType 传输单个简单类

型值,#{}括号中可以是 value 或其它名称。

可以自动对值添加 ’ ’ 单引号

${}表示拼接 sql 串

通过${}可以将 parameterType 传入的内容拼接在 sql 中且不进行 jdbc 类型转换, ${}可以接收简

单类型值或 pojo 属性值,如果 parameterType 传输单个简单类型值,${}括号中只能是 value。

比如order by id  这种的,以id排序  那么这个id 是没有单引号的,就是简单的SQL拼接,所以我们应该使用${} 而不是#{}

举例: ALTER TABLE (表名)  ADD  keycode(字段) varchar(500)

2.parameterType 配置参数

我们在上一章节中已经介绍了 SQL 语句传参,使用标签的 parameterType 属性来设定。该属性的取值可以是基本类型,引用类型(例如:String 类型),还可以是实体类类型(POJO 类)。同时也可以使用实体类的包装类,本章节将介绍如何使用实体类的包装类作为参数传递。

注意事项

基本类型和String我们可以直接写类型名称,也可以使用包名.类名的方式

例如 :

java.lang.String

实体类类型,目前我们只能使用全限定类名。

究其原因,是 mybaits 在加载时已经把常用的数据类型注册了别名,从而我们在使用时可以不写包名,而我们的是实体类并没有注册别名,所以必须写全限定类名。在 mybatis 的官方文档的说明(第 19 页)

3.resultType

resultType 属性可以指定结果集的类型,它支持基本类型和实体类类型。

我们在前面的 CRUD 案例中已经对此属性进行过应用了。

需要注意的是,它和 parameterType 一样,如果注册过类型别名的,可以直接使用别名。没有注册过的必须使用全限定类名。

例如:我们的实体类此时必须是全限定类名

同时,当是实体类名称时,还有一个要求,实体类中的属性名称必须和查询语句中的列名保持一致,否则无法实现封装(不区分大小写)

 

4.resultMap

我们在resultType ,提到在声明返回值类型为实体类型之后,实体中的属性必须和查询语句中的属性对应上,但是我们在开发的过程中也难免会遇到无法对应的情况。比如说我们在进行数据库设计的时候,多个单词往往是用_连接,但是在实体类中的属性往往采用小驼峰的方式命名。这就导致字段名无法对应上,这个时候我们就需要配置resultMap来解决这个问题了。

通过resultMap,我们可以指定查询结果字段和实体属性字段的映射关系。

<resultMap id="userResult" type="User">
<id column="id" property="id" /> 
<result property="nickname" column="nickname" /> 
<result property="schoolName" column="school_name" /> 
</resultMap>

配置插件

在mybatis-config.xml中,添加plugins标签配置,表示开启PageHelper插件

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration>     <settings>              <!-- 打开延迟加载的开关 -->              <setting name="lazyLoadingEnabled" value="true" />              <!-- 将积极加载改为消息加载即按需加载 -->              <setting name="aggressiveLazyLoading" value="false"/>          </settings>        <typeAliases>       <package name="com.how2java.pojo"/>     </typeAliases>     <plugins>         <plugin interceptor="com.github.pagehelper.PageInterceptor"></plugin>     </plugins>          <environments default="development">  .....     </environments>     <mappers> ...     </mappers> </configuration>

修改CategoryMapper.xml

limit注释掉,因为分页相关工作,会由PageHelper去做掉,不需要自己去写了

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper     PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"     "http://mybatis.org/dtd/mybatis-3-mapper.dtd">     <mapper namespace="com.how2java.pojo">         <select id="listCategory" resultType="Category">             select * from   t_category <!--                 <if test="start!=null and count!=null"> --> <!--                     limit #{start},#{count} --> <!--                 </if> -->         </select>         </mapper>

分页查询测试

查询很有意思,只需要在执行查询所有的调用之前,执行一条语句即可:

PageHelper.offsetPage(0, 5);

public class TestMybatis {     public static void main(String[] args) throws IOException, InterruptedException {         String resource = "mybatis-config.xml";         InputStream inputStream = Resources.getResourceAsStream(resource);         SqlSessionFactory sqlSessionFactory = newSqlSessionFactoryBuilder().build(inputStream);         SqlSession session = sqlSessionFactory.openSession();                PageHelper.offsetPage(0, 5);           List<Category> cs = session.selectList("listCategory");         for (Category c : cs) {             System.out.println(c.getName());         }           session.commit();         session.close();     } }

获取总数

public class TestMybatis {     public static void main(String[] args) throws IOException, InterruptedException {         String resource = "mybatis-config.xml";         InputStream inputStream = Resources.getResourceAsStream(resource);         SqlSessionFactory sqlSessionFactory = newSqlSessionFactoryBuilder().build(inputStream);         SqlSession session = sqlSessionFactory.openSession();                PageHelper.offsetPage(0, 5);           List<Category> cs = session.selectList("listCategory");         for (Category c : cs) {             System.out.println(c.getName());         }                   PageInfo pageInfo = new PageInfo<>(cs);         System.out.println("总数:"+pageInfo.getTotal());         System.out.println(pageInfo);           session.commit();         session.close();     } }

-------------------------------------------------------------------------------------------------------------------------------------

四、完成模糊查询

模糊查询

1. 修改UserMapper.xml,提供listUserByName查询语句

<select id="listUserByName" parameterType="string" resultType="User"> select * from t_user where username like concat('%',#{0},'%') </select>

2. 测试

@Test public void listUserByName() { SqlSession session = null; try { session = MybatisUtil.getSession(); List<User> list = session.selectList("User.listUserByName","d"); for (User user : list) { System.out.println(user); } } catch (Exception e) { e.printStackTrace(); } finally { MybatisUtil.closeSession(session); } }

多条件查询

结合前面的模糊查询,多一个id大于多少的条件

1. UserMapper.xml 准备sql语句

<select id="listUserByIdAndName" parameterType="map" resultType="User"> select * from t_user where id> #{id} and username like concat('%',#{username},'%') </select>

2. 测试代码

因为是多个参数,而session.selectList()方法又只接受一个参数对象,所以需要把多个参数放在Map里,然后把这个Map对象作为参数传递进去

Map<String,Object> params = new HashMap<>(); params.put("id", 8); params.put("username", "d"); List<User> ulist= session.selectList("User.listUserByIdAndName",params);

-------------------------------------------------------------------------------------------------------------------------------------

五、掌握动态SQL

动态SQL是MyBatis的一个强大特性之一,如果你有使用 JDBC 或其他 相似框架的经验,你就明白条件地串联 SQL 字符串在一起是多么的痛苦,确保不能忘了空 格或在列表的最后省略逗号。动态 SQL 可以彻底处理这种痛苦。 

动态 SQL 元素和使用 JSTL 或其他相似的基于 XML 的文本处理器相似。在 MyBatis 之 前的版本中,有很多的元素需要来了解。MyBatis 3 大大提升了它们,现在用不到原先一半 的元素就能工作了。MyBatis 采用功能强大的基于 OGNL 的表达式来消除其他元素。

· if

· choose (when, otherwise)

· where等

用法可参照API MyBatis3.2.3帮助文档(中文版).chm

创建产品表

create table t_product( id int NOT NULL AUTO_INCREMENT, name varchar(30) DEFAULT NULL, price float DEFAULT 0, cid int , PRIMARY KEY (id) )AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

新增6条产品数据

INSERT INTO t_product VALUES (1,'product a', 88.88, 1); INSERT INTO t_product VALUES (2,'product b', 88.88, 1); INSERT INTO t_product VALUES (3,'product c', 88.88, 1); INSERT INTO t_product VALUES (4,'product x', 88.88, 2); INSERT INTO t_product VALUES (5,'product y', 88.88, 2); INSERT INTO t_product VALUES (6,'product z', 88.88, 2);

创建Product实体类

public class Product {     private int id;     private String name;     private float price;     public int getId() {         return id;     }     public void setId(int id) {         this.id = id;     }     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     }     public float getPrice() {         return price;     }     public void setPrice(float price) {         this.price = price;     }     @Override     public String toString() {         return "Product [id=" + id + ", name=" + name + ", price=" + price + "]";     }

动态SQL导入

执行不同的条件限定,需要准备两条sql语句

假设需要对Product执行两条sql语句,一个是查询所有,一个是根据名称模糊查询。

那么按照现在的方式,必须提供两条sql语句:listProduct和listProductByName

然后在调用的时候,分别调用它们来执行。

在ProductMapper.xml添加如下代码

    <select id="listProduct" resultType="Product">          select * from t_product              </select>     <select id="listProductByName" resultType="Product">           select * from t_product where name like concat('%',#{name},'%')             </select>

在测试类进行测试

    System.out.println("查询所有的");     List<Product> ps = session.selectList("listProduct");     for (Product p : ps) {          System.out.println(p);     }               System.out.println("模糊查询");     Map<String,Object> params = new HashMap<>();     params.put("name","a");     List<Product> ps2 = session.selectList("listProductByName",params);     for (Product p : ps2) {          System.out.println(p);     } 

if标签

如果Product的字段比较多的话,为了应付各个字段的查询,那么就需要写多条sql语句,这样就变得难以维护。这个时候,就可以使用Mybatis 动态SQL里的if标签

<select id="listProduct" resultType="Product"> select * from t_product <if test="name!=null"> where name like concat('%',#{name},'%') </if> </select>

在测试类进行测试

    System.out.println("查询所有的");     List<Product> ps = session.selectList("listProduct");     for (Product p : ps) {          System.out.println(p);     }               System.out.println("模糊查询");     Map<String,Object> params = new HashMap<>();     params.put("name","a");     List<Product> ps2 = session.selectList("listProductByName",params);     for (Product p : ps2) {          System.out.println(p);     } 

where标签

基于上一个知识点if 标签进行

在ProductMapper.xml添加如下代码

如果要进行多条件判断,就会写成这样:

<select id="listProduct" resultType="Product"> select * from t_product <if test="name!=null"> where name like concat('%',#{name},'%') </if> <if test="price!=0"> and price > #{price} </if> </select>

这么写的问题是:当没有name参数,却有price参数的时候,执行的sql语句就会是:

select * from t_product and price > 10

这样执行就会报错

这个问题可以通过标签来解决,如代码所示

<select id="listProduct" resultType="Product"> select * from t_product <where> <if test="name!=null"> and name like concat('%',#{name},'%') </if> <if test="price!=null and price!=0"> and price > #{price} </if> </where> </select>

标签会进行自动判断

如果任何条件都不成立,那么就在sql语句里就不会出现where关键字

如果有任何条件成立,会自动去掉多出来的 and 或者 or。

所以在测试代码里

Map<String,Object> params = new HashMap<>(); //params.put("name","a"); params.put("price","10");

这个参数map,无论是否提供值都可以正常执行

set标签

where标签类似的,在update语句里也会碰到多个字段相关的问题。 在这种情况下,就可以使用set标签:

   <update id="updateProduct" parameterType="Product" >         update t_product         <set>             <if test="name != null">name=#{name},</if>             <if test="price != null">price=#{price}</if>         </set>          where id=#{id}        </update>

其效果与where标签类似,有数据的时候才进行设置。

测试:

Product p = new Product(); p.setId(6); p.setName("product zz"); p.setPrice(99.99f); session.update("updateProduct",p);

trim标签

trim 用来定制想要的功能,比如where标签就可以用

prefix :内容之前加的前缀 

suffix :内容之后加的后缀 

prefixOverrides:  属性会忽略通过管道分隔的文本序列

...

来替换

set标签就可以用

...

来替换

测试ProductMapper.xml

<select id="listProduct" resultType="Product">         select * from t_product         <trim prefix="WHERE" prefixOverrides="AND |OR ">             <if test="name!=null">                 name like concat('%',#{name},'%')             </if>                     <if test="price!=null and price!=0">                 price > #{price}             </if>         </trim>        </select> <update id="updateProduct" parameterType="Product" >         update t_product         <trim prefix="SET" suffixOverrides=",">             <if test="name != null">name=#{name},</if>             <if test="price != null">price=#{price},</if>         </trim>         where id=#{id}     </update>

choose、when、otherwise

类似于Java中的switch case default

在ProductMapper.xml文件中添加如下代码

<select id="listProduct" resultType="Product"> SELECT * FROM t_product <where> <choose> <when test="name != null"> and name like concat('%',#{name},'%') </when> <when test="price !=null and price != 0"> and price > #{price} </when> <otherwise> and id >1 </otherwise> </choose> </where> </select>

在测试类中添加如下代码测试

      Map<String,Object> params = new HashMap<>(); //    params.put("name","a"); //    params.put("price","10");       List<Product> ps = session.selectList("listProduct",params);       for (Product p : ps) {           System.out.println(p);       }

foreach标签

ProductMapper.xml

foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合。

foreach元素的属性主要有 item,index,collection,open,separator,close。

item集合中每一个元素进行迭代时的别名,

open该语句以什么开始,

separator在每次进行迭代之间以什么符号作为分隔 符,

close以什么结束,

在使用foreach的时候最关键的也是最容易出错的就是collection属性,

该属性是必须指定的,但是在不同情况 下,该属性的值是不一样的,

主要有一下3种情况:

1.     如果传入的是单参数且参数类型是一个List的时候,collection属性值为list

2.     如果传入的是单参数且参数类型是一个array数组的时候,collection的属性值为array

3.     如果传入的参数是多个的时候,我们就需要把它们封装成一个Map了

 <select id="listProduct" resultType="Product">        SELECT * FROM t_product            WHERE ID in                <foreach item="item" index="index" collection="list"                    open="(" separator="," close=")">                    #{item}                </foreach>  </select>

在测试类中添加如下代码测试

List<Integer> ids = new ArrayList();         ids.add(1);         ids.add(3);         ids.add(5);            List<Product> ps = session.selectList("listProduct",ids);       for (Product p : ps) {           System.out.println(p);       }

        ids.add(1);

bind标签

ProductMapper.xml

     <!-- 本来的模糊查询方式 --> <!--    <select id="listProduct" resultType="Product"> --> <!--             select * from  t_product  where name like concat('%',#{0},'%') --> <!--    </select> -->                       <select id="listProduct" resultType="Product">             <bind name="likename" value="'%' + name + '%'" />             select * from  t_product where name like #{likename}         </select>

             

在测试类中添加如下代码测试

Map<String, String> params =new HashMap();     params.put("name", "product");          List<Product> ps = session.selectList("listProduct",params);        for (Product p : ps) {            System.out.println(p);        }

六、关联查询

在项目中,某些实体类之间肯定有关联关系,比如一对一、多对一、一对多、多对多等,在mybatis 中可以通过association和collection,来处理这些关联关系。

1、一对多

对于产品类型来说,一种产品类型就对应了多个产品,那么在mybatis中我们可以通过collections解决。

1.1、创建产品表

create table t_product( id int NOT NULL AUTO_INCREMENT, name varchar(30) DEFAULT NULL, price float DEFAULT 0, cid int , PRIMARY KEY (id) )AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

1.2、创建产品类型表

create table t_category ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(32) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

1.3、清空t_category 和 t_product_ 表 新增2条分类数据,id分别是1,2 ;新增6条产品数据,分

别关联上述2条分类数据

delete from t_category; INSERT INTO t_category VALUES (1,'category1'); INSERT INTO t_category VALUES (2,'category2'); delete from t_product; INSERT INTO t_product VALUES (1,'product a', 88.88, 1); INSERT INTO t_product VALUES (2,'product b', 88.88, 1); INSERT INTO t_product VALUES (3,'product c', 88.88, 1); INSERT INTO t_product VALUES (4,'product x', 88.88, 2); INSERT INTO t_product VALUES (5,'product y', 88.88, 2); INSERT INTO t_product VALUES (6,'product z', 88.88, 2);

1.4、创建Product实体类

public class Product {     private int id;     private String name;     private float price;     public int getId() {         return id;     }     public void setId(int id) {         this.id = id;     }     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     }     public float getPrice() {         return price;     }     public void setPrice(float price) {         this.price = price;     }     @Override     public String toString() {         return "Product [id=" + id + ", name=" + name + ", price=" + price + "]";     }

1.5、创建Category实体

public class Category {     private int id;     private String name;     List<Product> products;     public int getId() {         return id;     }     public void setId(int id) {         this.id = id;     }     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     }     public List<Product> getProducts() {         return products;     }     public void setProducts(List<Product> products) {         this.products = products;     }     @Override     public String toString() {         return "Category [id=" + id + ", name=" + name + "]";     } }

1.6、创建CategoryMapper.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.test.pojo"> <resultMap type="Category" id="categoryBean"> <id column="cid" property="id" /> <result column="cname" property="name" /> <!-- 一对多的关系 --> <!-- property: 指的是集合属性的值, ofType:指的是集合中元素的类型 --> <collection property="products" ofType="Product"> <id column="pid" property="id" /> <result column="pname" property="name" /> <result column="price" property="price" /> </collection> </resultMap> <!-- 关联查询分类和产品表 --> <select id="listCategory" resultMap="categoryBean"> select c.*, p.*, c.id 'cid', p.id 'pid', c.name 'cname', p.name 'pname' from t_category c left join t_product p on c.id = p.cid </select> </mapper>

1.7、创建MyBatis测试类

 public static void main(String[] args) throws IOException {     String resource = "mybatis-config.xml";     InputStream inputStream = Resources.getResourceAsStream(resource);     SqlSessionFactory sqlSessionFactory = newSqlSessionFactoryBuilder().build(inputStream); SqlSession session = sqlSessionFactory.openSession();            List<Category> cs = session.selectList("listCategory");         for (Category c : cs) {             System.out.println(c);             List<Product> ps = c.getProducts();             for (Product p : ps) {                 System.out.println("\t"+p);             }         }         session.commit();         session.close();     }

2、多对一

对于产品类型来说,一种类型就对应了多个产品,但对于产品来说只能对应一种产品类型,这种情况,在mybatis中就可以通过association 解决。本知识点建立在一对多的基础上讲解多对一关系。

2.1、修改Product.java 添加Category对象属性

public class Product {     private int id;     ......     private Category category;           public Category getCategory() {         return category;     }     public void setCategory(Category category) {         this.category = category;     }     ......     @Override     public String toString() {         return "Product [id=" + id + ", name=" + name + ", price=" + price + "]";     } }

2.2、创建ProductMapper.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper     PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"     "http://mybatis.org/dtd/mybatis-3-mapper.dtd">     <mapper namespace="com.hanlin.pojo">         <resultMap type="Product" id="productBean">             <id column="pid" property="id" />             <result column="pname" property="name" />             <result column="price" property="price" />                   <!-- 多对一的关系 -->             <!-- property: 指的是属性名称, javaType:指的是属性的类型 -->             <association property="category" javaType="Category">                 <id column="cid" property="id"/>                 <result column="cname" property="name"/>             </association>         </resultMap>               <!-- 根据id查询Product, 关联将Orders查询出来 -->         <select id="listProduct" resultMap="productBean">             select c.*, p.*, c.id 'cid', p.id 'pid', c.name 'cname', p.name 'pname' from t_category c left join t_product p on c.id = p.cid         </select>        </mapper>

2.3、修改mybatis-config.xml

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration>     <typeAliases>       <package name="com.mjw.pojo"/>     </typeAliases>     <environments default="development">         <environment id="development">             <transactionManager type="JDBC"/>             <dataSource type="POOLED">             <property name="driver" value="com.mysql.jdbc.Driver"/>             <property name="url" value="jdbc:mysql://localhost:3306/ssm?characterEncoding=UTF-8"/>             <property name="username" value="root"/>             <property name="password" value="admin"/>             </dataSource>         </environment>     </environments>     <mappers>         <mapper resource="com/mjw/pojo/Category.xml"/>         <mapper resource="com/mjw/pojo/Product.xml"/>     </mappers> </configuration>

2.4、在测试类中测试

 public static void main(String[] args) throws IOException {         String resource = "mybatis-config.xml";         InputStream inputStream = Resources.getResourceAsStream(resource);         SqlSessionFactory sqlSessionFactory = newSqlSessionFactoryBuilder().build(inputStream);         SqlSession session = sqlSessionFactory.openSession();         List<Product> ps = session.selectList("listProduct");         for (Product p : ps) {             System.out.println(p+" 对应的分类是 \t "+ p.getCategory());         }         session.commit();         session.close();     }

 

国产算力Day 0实战适配:昇腾、寒武纪、摩尔线程上的大模型推理调优 在2026年5月的鲲鹏昇腾开发者大会上,昇腾宣布CANN全面开源开放,开放50+代码仓、800+算子,完成Triton、TileLang引擎100%接口兼容,并推出CANNBot算子智能体使单个算子开发效率提升5倍以上。在昇腾NPU上,这项技术充分释放了硬件的并行计算能力,使生成k个token的总延迟仅略高于一次主模型自回归解码。vLLM、SGLang等开源推理框架已成为事实标准,各家都在积极合入主线——昇腾有vLLM-Ascend插件,寒武纪有vLLM-MLU,摩尔线程的MUSA已合入SGLang主线。 阅读详情

相关推荐

【基于深度学习的脑电图识别】数据集篇:THE TUH EEG CORPUS: A Big Data Resource for Automated EEG Interpretation

【基于机器学习的脑电图识别】数据集篇:脑电信号自动判读的大数据摘要: 摘要: 这个数据集包括超过 25000 个脑电图研究,包括一个神经学家对测试的解释,一个简短的病人病史和关于病人的人口统计信息,如性别和年龄。这是第一次有足够的数据来支持最先进的机器学习算法的应用。在这篇论文中,我们使用了3762个语料库的会话子集,展示了从原始脑电图信号数据预测脑电图的一些基本属性的初步实验结果。在闭环测试中,...

梁瑛平的博客 5577

day58 Pyhton 框架Django 01

内容回顾   python基础   网路编程   并发编程   数据库   前端 osi7层 tcp/ip 5层模型 应用层 表示层 应用层 HTTP FTP DNS 会话层 传输层 传输层 TC...

weixin_30909575的博客 278

SOT全套AltiumDesigner封装库 包含SOT252 SOT23-5等

本封装库包含:SOT23SOT23-3 SOT23-5 SOT23-6 SOT23-6_DBV6 SOT23-8 SOT89SOT143SOT143BSOT223SOT223_SC73SOT353SOT363SOT665SOT753SOT-5SOT-23SOT-23-3SOT-23-3-123SOT-23-5SOT-23-5-XFXSOT-23-5LSOT-23-123SOT-23(6)SOT-23(DBV)SOT-89SOT-143SOT-223SOT-223(2-4)SOT-252SOT-363SOT-23BSOT-89

bootstrap table中文文档_Day58 前端框架Bootstrap介绍

目录bootstrap简介全局css样式组件js插件1、bootstrap简介bootstrap框架已经写好了很多页面样式,只需要下载文件,然后直接拷贝即可。在使用bootstrap时,所有的页面样式只需要你通过class来调节,建议使用v3版本。Bootstrap中文网​www.bootcss.comBootstrap 是最受欢迎的 HTML、CSS 和 JS 框架,用于开发响应式布局、移动设备...

weixin_39624980的博客 809

bootstrap怎样引用自己写好的js_Day58 前端框架Bootstrap介绍

目录bootstrap简介全局css样式组件js插件1、bootstrap简介bootstrap框架已经写好了很多页面样式,只需要下载文件,然后直接拷贝即可。在使用bootstrap时,所有的页面样式只需要你通过class来调节,建议使用v3版本。Bootstrap中文网​www.bootcss.comBootstrap 是最受欢迎的 HTML、CSS 和 JS 框架,用于开发响应式布局、移动设备...

weixin_39709367的博客 812

Java学习笔记-Day58 监听器、分页、Layui前端框架

Java学习笔记-Day58 监听器、分页一、监听器1、简介2、监听器相关的API2.1、事件类2.2、监听器接口3、监听器的开发及配置4、Eclispe创建监听器5、案例 (统计在线人数)二、分页1、分页的方式3、分页需要的要素三、Layui前端框架   一、监听器   1、简介   事件发生的时间往往是不确定的,当事件发生的时候需要进行一些处理时,就可以使用监听器。   2、监听器相关的API   监听器相关的API包括 事件类 以及 监听器接口。事件类定义了事件类型,监听器接口定义了监听事件的方法。

qq_42141141的博客 498

day58 JavaWeb框架阶段——SSM框架练习(用户数据后台管理,登录拦截器)

SSM练习 今日源码及素材: 链接:https://pan.baidu.com/s/19XDTuRre1A3JFlKhm2Aqbw 提取码:ls63 需求: 1.角色列表展示和添加删除操作 2.用户列表展示和添加删除操作 3.删除用户和角色操作 4.用户登录操作 5.配置登录拦截器(不登录无法查看和更改用户信息,该功能默认关闭,请在spring-mvc.xml中打开) 效果展示 01-Spr...

qq_38454176的博客 493

Day58 Java框架 SSH案例_CRM(六) Easyui&列表展示

EasyUI 一.概述 jQuery EasyUI是一组基于jQuery的UI插件集合体,而jQuery EasyUI的目标就是帮助web开发者更轻松的打造出功能丰富并且美观的UI界面 . 常见的版本 : EasyUI 1.4 和1.5 下载 : http://www.jeasyui.net/download/ 二.EasyUI的使用 引入EasyUI的开发JS和CSS EasyUI的...

ambition 273

Python Day 58 Django框架、路由系统、视图函数、Django框架ORM框架(单表操作、一对多表、正反查询、双下划线方法)...

  ##Django框架路由系统 1、伪静态 cnblogs:网站中的地址: https://www.cnblogs.c om/linhaifeng/articles/7133167.html 自己项目中的访问地址: http://127.0.0.1:8000/up_studnet/?id=12 如何...

dengweihua2701的博客 230

框架 day58 BOS项目练习(基于activiti物流配送流程,启动,查询,办理,项目知识点复习)

框架 day58 BOS项目练习(基于activiti物流配送流程,启动,查询,办理,项目知识点复习)

飛白的学习笔记 5296

智谱GLM-5.1深度评测:8小时连续工作,开源大模型进入“工程交付“新纪元

全球首个通过真实工程任务验证8小时持续工作能力的开源模型,在SWE-Bench Pro上超越GPT-5.4和Claude Opus 4.6登顶全球第一,重新定义AI从"回答问题"到"完成项目"的范式转变。有个AI,在真实工程任务中连续工作了8小时,完成了1200多步操作,从零搭建了一套完整的Linux桌面环境。但真实工程任务不一样:你可能需要先查资料,再写代码,发现报错后换思路,再试,再报错,再换……当然,这个"工程师"还有不足——复杂推理、长文本理解、多模态处理,这些都还有提升空间。

datayx的文章 594

Day58 算法训练营

方法二:从一个陆地节点开始,判断向上方向和向左方向是否为陆地,若为陆地,说明当前陆地节点和方向陆地节点是两个相邻节点,相邻节点有2条边是重叠的,故最后应该将所有的陆地节点 * 4算出总边长数,再减去重叠的节点边长数(重叠陆地节点 * 2),遍历结束将该结果返回即可。如果是处理当前访问的节点,当前节点如果是true,说明已经访问过该节点,直接终止本层递归,如果不是true,则将此节点置为true,开始本层递归。本题有两种思路可以AC,但Java语言在平台上提交是时间超限,C++就没问题,都是一样的思路。

qq_54162207的博客 1080

代码随想录第58day01

原理就是定义两个指针,一个为快指针,一个为慢指针,快指针先遍历,再从里面写一个判断语句,如果数组值与目标值不相等,那么就可以把快指针对应的元素值复制到慢指针对应的数组的位置,这样就能实现与目标值相等的元素能被覆盖,以此完成两重for循环完成的任务,代码如下:`解析:这题还没看双指针怎么解,我用了暴力解,我的思路如下,注意到nums[i]的最大值为10^4 ,数组空间最大也是这么多,就想到用hash映射到重新开辟的数组里面,在遍历新数组里面对应的值,来实现求他的下标的平方存在数组里面,以至于排好序。

qq_64919637的博客 809

代码随想录-算法训练营day58(休息,复习与总结)

休息,复习与总结

weixin_61931006的博客 154

wy的leetcode刷题记录_Day58

力扣每日一题简单模拟左右抵消和二叉平衡搜索树 1769. 移动所有球到每个盒子所需的最小操作数和108. 将有序数组转换为二叉搜索树

m0_54015435的博客 320

代码训练营 day58

今天主要学习了图的一系列操作,今天题目思路还行,但是代码实现还有点困难。加油,坚持打卡的第58天。

qq_44639909的博客 1091

day58

day58 做一个小型的学员管理系统 ##刷新页面,到一个页面是GET,提交什么的是post,a标签跳转是get方式 render把py里的东西传到html文件里 window.confirm('是否确认删除'); #新url的方式 ###更新老师等 ##urls.py的内容 from django.conf.urls import url from djang...

weixin_30835923的博客 114

代码随想录第58day02

分析:题意为在一个数组中找到最小连续的字数组的和大于等于target,那么就有很多种可能了,可能之前的数都很小,但是刚好遇到一个大数(大数大于等于target)使得和大于等于target,那么此时最小字数组长度应该是1,由此,本题我们可以用滑动窗口思想来解决,附带。,用双指针的思想来解决。输入:target = 11, nums = [1,1,1,1,1,1,1,1]输入:target = 7, nums = [2,3,1,2,4,3]输出:[[1,2,3],[8,9,4],[7,6,5]]

qq_64919637的博客 390

MySQL 事务、四大隔离级别、MVCC完整原理笔记|案例+问题演示

本文完整讲解MySQL InnoDB事务全套核心知识点,从并发数据错乱问题引出事务概念,详解事务四大特性ACID底层实现原理:原子性依靠undo log、持久性依靠redo log、隔离性由锁+MVCC保障,一致性为最终状态由技术与业务代码共同实现。通过4组客户端宕机实操实验区分自动提交、显式/隐式事务提交与回滚机制。依次介绍四大隔离级别,脏读、不可重复读、幻读三类并发问题,深入拆解MVCC多版本并发控制、隐藏列、undo版本链、ReadView快照可见性规则,对比RC与RR隔离级别快照生成差异。

m0_68447088的博客 293
上一篇: javaWeb-day-57
下一篇: 框架-day-61
落华见樱
博客等级 码龄6年 11粉丝 · 53原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值