-
自己手写 SQL 分页或使用分页插件 PageHelper,去数据库查询指定条数的分页数据的形式。
-
使用 MyBatis 自带的 RowBounds 进行分页,它是一次性查询很多数据,然后在数据中再进行检索
-
Mybatis基础1. 相关概念1.1框架介绍框架是一款半成品软件,我们可以基于这个半成品软件继续开发,来完成我们个性化的需求!简单来说, 就是"框架把一些不变的东西提前写好, 让我们能更快更好的完成程序的开发"1.2 ORM介绍ORM(Object Relational Mapping): 对象关系映射object:指的是实体对象,javabeanrelational:指的是关系型数据库,比如mysqlMapping: 映射,一 一对应的关系简单来说,ORM可以实现对象与数据库表之间的自动映射1.3 Mybatismybatis 是一个优秀的基于java的, 并且实现了ORM映射的持久层框架,它内部封装了jdbcmybatis通过xml或注解的方式实现对数据库的持久化操作MyBatis官网地址:http://www.mybatis.org/mybatis-3/2. 快速入门2.1 MyBatis开发步骤①添加MyBatis的jar包mysql-connector-java-5.1.37-bin.jarmybatis-3.5.3.jarog4j-1.2.17.jar②编写实体类(对应数据库中的表)//学生类//该类要和数据库表进行一一对应public class Student { private Integer id; private String name; private Integer age; //省略get个set方法}③编写核心配置文件SqlMapConfig.xml<?xml version="1.0" encoding="UTF-8" ?><!--MyBatis的DTD约束--><!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"><!--configuration 核心根标签--><configuration> <!--environments配置数据库环境,环境可以有多个。default属性指定使用的是哪个--> <environments default="mysql"> <!--environment配置数据库环境 id属性唯一标识--> <environment id="mysql"> <!-- transactionManager事务管理。 type属性,采用JDBC默认的事务--> <transactionManager type="JDBC"></transactionManager> <!-- dataSource数据源信息 type属性 连接池--> <dataSource type="POOLED"> <!-- property获取数据库连接的配置信息 --> <property name="driver" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://192.168.59.143:3306/数据库表名" /> <property name="username" value="数据库账户" /> <property name="password" value="数据库密码" /> </dataSource> </environment> </environments> <!-- mappers引入映射配置文件 --> <mappers> <!-- resource属性指定映射配置文件的位置 --> <mapper resource="StudentMapper.xml"/> </mappers></configuration>④编写映射配置文件<?xml version="1.0" encoding="UTF-8" ?><!--MyBatis的DTD约束 直接复制--><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><!-- mapper:核心根标签 namespace属性:名称空间 --><mapper namespace="StudentMapper"> <!-- select:查询功能的标签. insert:添加 update:修改 delete:删除 id属性:唯一标识 resultType属性:指定结果映射对象类型 parameterType属性:指定参数映射对象类型 --> <select id="selectAll" resultType="com.itheima.bean.Student"> SELECT * FROM student </select> </mapper>⑤编写测试类@Testpublic void selectAll() throws Exception{ //1.加载核心配置文件 InputStream is = Resources.getResourceAsStream("MyBatisConfig.xml"); //2.获取SqlSession工厂对象 SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is); //3.通过SqlSession工厂对象获取SqlSession对象 SqlSession sqlSession = sqlSessionFactory.openSession(); //4.执行映射配置文件中的sql语句,并接收结果(参数是StudentMapper.xml中的selectAll) List<Student> list = sqlSession.selectList("StudentMapper.selectAll"); //5.处理结果 for (Student stu : list) { System.out.println(stu); } //6.释放资源 sqlSession.close(); is.close();}3. 映射配置文件3.1 配置信息<?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="StudentMapper"> <insert id="insert" parameterType="student"> INSERT INTO student VALUES (#{id},#{name},#{age}) </insert> <update id="update" parameterType="student"> UPDATE student SET name = #{name},age = #{age} WHERE id = #{id} </update> <delete id="delete" parameterType="int"> DELETE FROM student WHERE id = #{id} </delete> <select id="selectAll" resultType="student"> SELECT * FROM student </select> <select id="selectById" resultType="student" parameterType="int"> SELECT * FROM student WHERE id = #{id} </select></mapper3.2 注意事项//简单类型:基本数据类型+String 复杂类型:除了基本数据类型和String1.参数是简单类型,则parameterType可以省略2.参数如果只有一个,且是简单类型时,#{id}可以随便写,都可以获取参数的值3.如果参数是复杂类型,则#{id}就相当于调用参数的getId方法,获取对应的参数值4.返回值是简单类型,则resultType可以省略5.返回值是集合类型,则resultType只写集合中元素的数据类型4. 核心配置文件4.1 引入外部properties① jdbc.propertiesdriver=com.mysql.jdbc.Driverurl=jdbc:mysql://192.168.59.143:3306/db1username=roootpassword=itheima② 引入配置文件<!--在MyBatis的核心配置文件中,引入数据库连接的配置文件--><properties resource="jdbc.properties"/>③ 获取配置信息<!-- 在MyBatis的核心配置文件中, 获取引入的properties文件中的配置信息 --><property name="driver" value="${driver}" /><property name="url" value="${url}" /><property name="username" value="${username}" /><property name="password" value="${password}" />4.2 起别名4.2.1 语法<!--起别名--><typeAliases> <!-- 给Student类起别名为"student" --> <typeAlias type="com.itheima.bean.Student" alias="student"/> <!-- 给com.itheima.bean包下所有的类起别名,别名为类名的小写名字 --> <!--<package name="com.itheima.bean"/>--> </typeAliase></typeAliases>4.2.1 作用当给实体类起别名后, 在MyBatis映射配置文件中的参数或返回值中, 可以直接使用别名, 并且别名不区分大小写15. 补充-selectKey标签5.1 概述selectKey标签只能用在增删改语句中, 它可以在"增删改"语句执行前后, 增加对应操作.5.2 案例<insert id="insert" parameterType="student"> <selectKey keyProperty="id" order="AFTER" > SELECT LAST_INSERT_ID() </selectKey> INSERT INTO student VALUES (#{id},#{name},#{age})</insert>
-
怎么利用MyBatis传List类型参数到数据库存储过程中实现批量插入数据?MyBatis中参数是List类型时怎么处理?大家都知道MyBatis批处理大量数据是很难做到事务回滚的(事务由Spring管理),都将逻辑写在存储中又是及其头疼的一件事(参数长度也有限制),那么我想的是将参数在后台封装为单个或多个list集合,直接通过MyBatis将此参数传到数据库存储过程中,一来摆脱了MyBatis批量插入数据的诸多限制(例如:不能实时返回主键、foreach标签循环集合长度有限制),二来就是在存储中灵活的控制事务,但是这又会涉及两个问题,MyBatis的xml文件中该怎么封装,利用BaseTypeHandler吗?对于这个问题,经过一天的研究终于算是跑通了,说一下解决办法:1.建立数据库表,大家应该都有自己的库表了,所以这一步基本上就可以跳过了。我之所以在这里把库表贴出来是为了让大家对应里面的参数。数据库表:create table ZD_UNIT_MENU ( unit_id VARCHAR2(32), menu_id VARCHAR2(32) ) 2.在数据库中建立相应的java对象(Oracle中的类型)和数组:CREATE OR REPLACE TYPE unit_menu_obj AS OBJECT( unitId VARCHAR2(32), menuId VARCHAR2(32) ); CREATE OR REPLACE TYPE unit_menu_table AS table OF unit_menu_obj; 3.存储过程:create or replace procedure save_unit_power(list0 in unit_menu_table,result0 out int) as sql_bind varchar(200); begin FOR i IN 1 .. list0.count LOOP sql_bind := 'insert into ZD_UNIT_MENU(UNIT_ID,MENU_ID) values('''||list0(i).unitId||''', '''||list0(i).menuId||''' )'; execute immediate sql_bind; end loop; commit; --返回结果,执行成功的话返回1 result0 := 1; --捕捉异常,回滚操作 EXCEPTION WHEN OTHERS THEN result0 := -1;--执行失败的话返回-1 ROLLBACK; end save_unit_power; 4.再看看mybatis的配置吧:<parameterMap type="java.util.Map" id="_map"> <parameter property="list0" jdbcType="ARRAY" javaType="java.util.List" mode="IN" typeHandler="com.zd.util.ListHandler"/> <parameter property="result0" jdbcType="DECIMAL" javaType="java.lang.Integer" mode="OUT" /> </parameterMap> <select id="addUnitPower" statementType="CALLABLE" parameterMap="_map"> <![CDATA[ CALL save_unit_power(?,?) ]]> </select> 5.看看我是如何调用的?我直接贴我的server代码了,dao层的就没必要了: List<UnitMenu> list = new ArrayList<UnitMenu>(); Map<String, Object> _map = new HashMap<String, Object>(); String[] menuIds = menuTreeIds.split(","); JSONObject job = new JSONObject(); int result = -1; for(int i = 0; i < menuIds.length; i++){ UnitMenu um = new UnitMenu(); um.setMenuId(menuIds[i]); um.setUnitId(unitId); list.add(um); } _map.put("list0", list); _map.put("result0", ""); unitMenuMapper.addUnitPower(_map); System.out.println("================================================_map = "+_map.toString()); result = (Integer)_map.get("result0"); System.out.println("================================================result = "+result);
-
求高手分享心得
-
(1)Mybatis和hibernate不同,它不完全是一个ORM框架,因为MyBatis需要程序员自己编写Sql语句。(2)Mybatis直接编写原生态sql,可以严格控制sql执行性能,灵活度高,非常适合对关系数据模型要求不高的软件开发,因为这类软件需求变化频繁,一但需求变化要求迅速输出成果。但是灵活的前提是mybatis无法做到数据库无关性,如果需要实现支持多种数据库的软件,则需要自定义多套sql映射文件,工作量大。(3)Hibernate对象/关系映射能力强,数据库无关性好,对于关系模型要求高的软件,如果用hibernate开发可以节省很多代码,提高效率。
-
5
-
4
-
MyBatis 本是apache 的一个开源项目iBatis,2010 年这个项目由apache 迁移到了google,并更名为MyBatis。2013 年迁移到Github。MyBatis 是一个优秀的基于Java 的持久层框架,它内部封装了JDBC,使开发者只需关注SQL 语句本身,而不用再花费精力去处理诸如注册驱动、创建Connection、配置Statement等繁杂过程。Mybatis通过xml 或注解的方式将要执行的各种statement(statement、preparedStatement等)配置起来,并通过Java 对象和Statement 中SQL 的动态参数进行映射生成最终执行的SQL 语句,最后由MyBatis 框架执行SQL 并将结果映射成Java 对象并返回。MyBatis 的可以在github 官网下载:https://github.com/mybatis
-
(1)数据库链接创建、释放频繁造成系统资源浪费从而影响系统性能,如果使用数据库链接池可解决此问题。解决:在SqlMapConfig.xml中配置数据链接池,使用连接池管理数据库链接。(2)Sql语句写在代码中造成代码不易维护,实际应用sql变化的可能较大,sql变动需要改变java代码。解决:将Sql语句配置在XXXXmapper.xml文件中与java代码分离。(3)向sql语句传参数麻烦,因为sql语句的where条件不一定,可能多也可能少,占位符需要和参数一一对应。解决:Mybatis自动将java对象映射至sql语句,通过statement中的parameterType定义输入参数的类型。(4)对结果集解析麻烦,sql变化导致解析代码变化,且解析前需要遍历,如果能将数据库记录封装成pojo对象解析比较方便。解决:Mybatis自动将sql执行结果映射至java对象,通过statement中的resultType定义输出结果的类型。
-
1、mybatis框架执行过程:(1)配置mybatis的配置文件,SqlMapConfig.xml(名称不固定)(2)通过配置文件,加载mybatis运行环境,创建SqlSessionFactory会话工厂 SqlSessionFactory在实际使用时按单例方式。(3)通过SqlSessionFactory创建SqlSession SqlSession是一个面向用户接口(提供操作数据库方法),实现对象是线程不安全的, 建议sqlSession应用场合在方法体内。(4)调用sqlSession的方法去操作数据。 如果需要提交事务,需要执行SqlSession的commit()方法。(5)释放资源,关闭SqlSession 2、输入映射:parameterType:指定输入参数类型可以简单类型、pojo、hashmap。。对于综合查询,建议parameterType使用包装的pojo,有利于系统 扩展。 3、输出映射:resultType:查询到的列名和resultType指定的pojo的属性名一致,才能映射成功。reusltMap:可以通过resultMap 完成一些高级映射。如果查询到的列名和映射的pojo的属性名不一致时,通过resultMap设置列名和属性名之间的对应关系(映射关系)。可以完成映射。 4、dao及实现类开发问题总结(1)dao接口实现类中存在大量模板方法,设想能否将这些代码提取出来,大大减轻程序员的工作量;(2)调用sqlsession方法时将statement的id硬编码了(3)调用sqlsession方法时参入的变量,由于sqlsession方法是用泛型,即使变量类型传入错误,在编译阶段也不报错。 5、mapper代理实现总结Mapper接口开发方法只需要程序员编写Mapper接口(相当于Dao接口),由Mybatis框架根据接口定义创建接口的动态代理对象,代理对象的方法体同上边Dao接口实现类方法。Mapper接口开发需要遵循以下规范:(1)Mapper.xml文件中的namespace与mapper接口的类路径相同。(2)Mapper接口方法名和Mapper.xml中定义的每个statement的id相同 (3)Mapper接口方法的输入参数类型和mapper.xml中定义的每个sql 的parameterType的类型相同(4)Mapper接口方法的输出参数类型和mapper.xml中定义的每个sql的resultType的类型相同
-
------------------2018-08-23 09:03:16,990 [ERROR] invoke failed, invocation=PRODUCER rest collector.collector.helloworld org.apache.servicecomb.swagger.invocation.exception.DefaultExceptionToResponseConverter.convert(DefaultExceptionToResponseConverter.java:35)java.lang.NullPointerExceptionat com.huawei.cse.porter.controller.CollectorImpl.helloworld(CollectorImpl.java:49)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.apache.servicecomb.swagger.engine.SwaggerProducerOperation.doInvoke(SwaggerProducerOperation.java:148)at org.apache.servicecomb.swagger.engine.SwaggerProducerOperation.syncInvoke(SwaggerProducerOperation.java:139)at org.apache.servicecomb.swagger.engine.SwaggerProducerOperation.invoke(SwaggerProducerOperation.java:109)at org.apache.servicecomb.core.handler.impl.ProducerOperationHandler.handle(ProducerOperationHandler.java:40)at org.apache.servicecomb.core.Invocation.next(Invocation.java:148)at org.apache.servicecomb.bizkeeper.BizkeeperCommand.lambda$construct$2(BizkeeperCommand.java:79)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.Observable.unsafeSubscribe(Observable.java:8666)at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:52)at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:36)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.Observable.unsafeSubscribe(Observable.java:8666)at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:52)at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:36)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.Observable.unsafeSubscribe(Observable.java:8666)at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:52)at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:36)at rx.Observable.subscribe(Observable.java:8759)at rx.Observable.subscribe(Observable.java:8726)at rx.Observable.subscribe(Observable.java:8619)at org.apache.servicecomb.bizkeeper.BizkeeperHandler.handle(BizkeeperHandler.java:77)at org.apache.servicecomb.core.Invocation.next(Invocation.java:148)at com.huawei.paas.cse.tcc.handler.ProviderTccTransactionHandler.handle(ProviderTccTransactionHandler.java:59)at org.apache.servicecomb.core.Invocation.next(Invocation.java:148)at org.apache.servicecomb.qps.ProviderQpsFlowControlHandler.handle(ProviderQpsFlowControlHandler.java:50)at org.apache.servicecomb.core.Invocation.next(Invocation.java:148)at com.huawei.paas.cse.handler.stats.PerfStatsHandler.handle(PerfStatsHandler.java:60)at org.apache.servicecomb.core.Invocation.next(Invocation.java:148)at org.apache.servicecomb.core.handler.ShutdownHookHandler.handle(ShutdownHookHandler.java:68)at org.apache.servicecomb.core.Invocation.next(Invocation.java:148)at org.apache.servicecomb.common.rest.AbstractRestInvocation.doInvoke(AbstractRestInvocation.java:189)at org.apache.servicecomb.common.rest.AbstractRestInvocation.invoke(AbstractRestInvocation.java:165)at org.apache.servicecomb.common.rest.AbstractRestInvocation.runOnExecutor(AbstractRestInvocation.java:150)at org.apache.servicecomb.common.rest.AbstractRestInvocation.lambda$scheduleInvocation$0(AbstractRestInvocation.java:133)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)at java.lang.Thread.run(Thread.java:748)2018-08-23 09:03:16,995 [WARN] bizkeeper command failed due to:InvocationException: code=590;msg=CommonExceptionData [message=Cse Internal Server Error] org.apache.servicecomb.bizkeeper.BizkeeperCommand.lambda$null$1(BizkeeperCommand.java:82)2018-08-23 09:03:16,996 [WARN] bizkeeper execution error org.apache.servicecomb.bizkeeper.BizkeeperHandler$1.onExecutionError(BizkeeperHandler.java:54)InvocationException: code=590;msg=CommonExceptionData [message=Cse Internal Server Error]at org.apache.servicecomb.swagger.invocation.exception.ExceptionFactory.d**ate(ExceptionFactory.java:79)at org.apache.servicecomb.swagger.invocation.exception.ExceptionFactory.convertException(ExceptionFactory.java:124)at org.apache.servicecomb.swagger.invocation.exception.ExceptionFactory.convertProducerException(ExceptionFactory.java:97)at org.apache.servicecomb.swagger.invocation.Response.createProducerFail(Response.java:134)at org.apache.servicecomb.swagger.invocation.Response.producerFailResp(Response.java:145)at org.apache.servicecomb.swagger.invocation.exception.DefaultExceptionToResponseConverter.convert(DefaultExceptionToResponseConverter.java:36)at org.apache.servicecomb.swagger.invocation.exception.ExceptionToResponseConverters.convertExceptionToResponse(ExceptionToResponseConverters.java:47)at org.apache.servicecomb.swagger.invocation.exception.ExceptionFactory.convertExceptionToResponse(ExceptionFactory.java:128)at org.apache.servicecomb.swagger.engine.SwaggerProducerOperation.proces**ception(SwaggerProducerOperation.java:161)at org.apache.servicecomb.swagger.engine.SwaggerProducerOperation.doInvoke(SwaggerProducerOperation.java:151)at org.apache.servicecomb.swagger.engine.SwaggerProducerOperation.syncInvoke(SwaggerProducerOperation.java:139)at org.apache.servicecomb.swagger.engine.SwaggerProducerOperation.invoke(SwaggerProducerOperation.java:109)at org.apache.servicecomb.core.handler.impl.ProducerOperationHandler.handle(ProducerOperationHandler.java:40)at org.apache.servicecomb.core.Invocation.next(Invocation.java:148)at org.apache.servicecomb.bizkeeper.BizkeeperCommand.lambda$construct$2(BizkeeperCommand.java:79)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.Observable.unsafeSubscribe(Observable.java:8666)at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:52)at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:36)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.Observable.unsafeSubscribe(Observable.java:8666)at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:52)at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:36)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)at rx.Observable.unsafeSubscribe(Observable.java:8666)at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:52)at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:36)at rx.Observable.subscribe(Observable.java:8759)at rx.Observable.subscribe(Observable.java:8726)at rx.Observable.subscribe(Observable.java:8619)at org.apache.servicecomb.bizkeeper.BizkeeperHandler.handle(BizkeeperHandler.java:77)at org.apache.servicecomb.core.Invocation.next(Invocation.java:148)at com.huawei.paas.cse.tcc.handler.ProviderTccTransactionHandler.handle(ProviderTccTransactionHandler.java:59)at org.apache.servicecomb.core.Invocation.next(Invocation.java:148)at org.apache.servicecomb.qps.ProviderQpsFlowControlHandler.handle(ProviderQpsFlowControlHandler.java:50)at org.apache.servicecomb.core.Invocation.next(Invocation.java:148)at com.huawei.paas.cse.handler.stats.PerfStatsHandler.handle(PerfStatsHandler.java:60)at org.apache.servicecomb.core.Invocation.next(Invocation.java:148)at org.apache.servicecomb.core.handler.ShutdownHookHandler.handle(ShutdownHookHandler.java:68)at org.apache.servicecomb.core.Invocation.next(Invocation.java:148)at org.apache.servicecomb.common.rest.AbstractRestInvocation.doInvoke(AbstractRestInvocation.java:189)at org.apache.servicecomb.common.rest.AbstractRestInvocation.invoke(AbstractRestInvocation.java:165)at org.apache.servicecomb.common.rest.AbstractRestInvocation.runOnExecutor(AbstractRestInvocation.java:150)at org.apache.servicecomb.common.rest.AbstractRestInvocation.lambda$scheduleInvocation$0(AbstractRestInvocation.java:133)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)at java.lang.Thread.run(Thread.java:748)Caused by: java.lang.NullPointerExceptionat com.huawei.cse.porter.controller.CollectorImpl.helloworld(CollectorImpl.java:49)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.apache.servicecomb.swagger.engine.SwaggerProducerOperation.doInvoke(SwaggerProducerOperation.java:148)... 60 more
上滑加载中
推荐直播
-
全面解析华为云EI-API服务:理论基础与实践应用指南
2024/11/29 周五 18:20-20:20
Alex 华为云学堂技术讲师
本期直播给大家带来的是理论与实践结合的华为云EI-API的服务介绍。从“主要功能,应用场景,实践案例,调用流程”四个维度来深入解析“语音交互API,文字识别API,自然语言处理API,图像识别API及图像搜索API”五大场景下API服务,同时结合实验,来加深开发者对API服务理解。
回顾中 -
企业员工、应届毕业生、在读研究生共探项目实践
2024/12/02 周一 19:00-21:00
姚圣伟 在职软件工程师 昇腾社区优秀开发者 华为云云享专家 HCDG天津地区发起人
大神带你一键了解和掌握LeakyReLU自定义算子在ONNX网络中应用和优化技巧,在线分享如何入门,以及在工作中如何结合实际项目进行学习
即将直播 -
昇腾云服务ModelArts深度解析:理论基础与实践应用指南
2024/12/03 周二 14:30-16:30
Alex 华为云学堂技术讲师
如何快速创建和部署模型,管理全周期AI工作流呢?本期直播聚焦华为昇腾云服务ModelArts一站式AI开发平台功能介绍,同时结合基于ModelArts 的实践性实验,帮助开发者从理论到实验更好地理解和使用ModelArts。
去报名
热门标签