使用 MongoDB 实现分页查询与条件查询中的注意事项
引言[scode type="share" size="simple"]在基于Spring Data MongoDB的开发中，分页与条件查询是高频操作，但其实现细节中存在诸多易错点。本文结合代码实例与典型场景，深入剖析五大核心问题及优化方案，并补充性能优化与设计规范。[/scode]一、基础代码示例与问题背景Pageable pageable = PageRequest.of(page-1, size, Sort.by("orderNumber").descending()); Query query = new Query(); // 动态条件构建 if (orderNumber != null) { query.addCriteria(Criteria.where("orderNumber").is(Long.parseLong(orderNumber))); } if (consignee != null) { query.addCriteria(Criteria.where("consignee").regex(consignee, "i")); } if (beginTime != null || endTime != null) { handleDateRange(query, beginTime, endTime); // 日期范围处理封装 } // 总条数与分页结果查询 long total = mongoTemplate.count(query, OrderEntity.class); query.with(pageable); List<OrderEntity> entities = mongoTemplate.find(query, OrderEntity.class);二、核心问题与解决方案1. 分页操作污染总条数计算问题现象若先调用query.with(pageable)再执行count()，分页限制（如skip/limit）会导致总条数统计错误。解决方案严格分离统计与分页阶段：// 阶段一：统计总数（未分页） long total = mongoTemplate.count(query, Order.class); // 阶段二：应用分页参数 query.with(pageable); List<Order> data = mongoTemplate.find(query, Order.class);2. 类型不匹配导致查询失效典型场景数据库字段类型为Long，但Java条件传递String类型值时，因MongoDB类型强校验导致匹配失败。优化建议使用统一类型转换工具：public void addLongCriteria(Query query, String field, String value) { if (StringUtils.isNotEmpty(value)) { try { query.addCriteria(Criteria.where(field).is(Long.parseLong(value))); } catch (NumberFormatException e) { throw new IllegalArgumentException("字段["+field+"]必须为数字类型"); } } }3. 正则表达式大小写敏感问题技术细节Criteria.regex()默认大小写敏感，需显式添加"i"修饰符实现模糊匹配。扩展方案支持动态大小写控制：String regexOptions = caseSensitive ? "" : "i"; criteria.regex(value, regexOptions);4. 日期范围查询条件冲突错误示例// 错误：多次添加createdAt条件 if (beginTime != null) query.addCriteria(Criteria.where("createdAt").gte(beginTime)); if (endTime != null) query.addCriteria(Criteria.where("createdAt").lte(endTime));正确实践单条件链式构建：Criteria dateCriteria = new Criteria(); if (beginTime != null) dateCriteria.gte(beginTime); if (endTime != null) dateCriteria.lte(endTime); if (beginTime != null || endTime != null) { query.addCriteria(dateCriteria); }5. 动态条件导致分页与总数不一致根本原因分页查询与总数统计的Query对象状态不同步，如中间发生条件修改。防御式编程使用深拷贝保证条件一致性：Query countQuery = new Query().addCriteria(query.getCriteria()); long total = mongoTemplate.count(countQuery, Order.class);三、高级优化策略1. 深分页性能优化问题传统skip+limit在数据量过大时性能急剧下降（O(N)复杂度）。替代方案游标分页法：基于最后记录ID的连续查询// 首次查询 query.limit(size).with(Sort.by(Sort.Direction.DESC, "createTime")); List<Order> data = mongoTemplate.find(query, Order.class); // 后续查询（基于末条记录的createTime） Object lastValue = data.get(data.size()-1).getCreateTime(); query.addCriteria(Criteria.where("createTime").lt(lastValue));2. 索引设计规范排序字段必索引：若分页含order by createTime，需为createTime建立索引复合索引顺序：遵循ESR原则（等值→排序→范围）// 示例：等值查询(status) + 排序(createTime) + 范围(amount) @CompoundIndex(def = "{'status':1, 'createTime':-1, 'amount':1}")3. 查询结果投影优化减少返回字段提升性能：query.fields().include("orderNo", "createTime").exclude("_id");4. 事务与一致性保障在分布式事务场景中：使用@Transactional注解声明事务边界避免长事务，控制操作粒度若需跨集合事务，需配置MongoDB副本集四、总结与最佳实践分离统计与分页阶段，防止条件污染类型校验前置，避免隐式转换异常正则表达式显式声明匹配模式范围条件链式构建，规避字段冲突游标分页替代skip，提升大数据量性能索引策略结合ESR原则，最大化查询效率通过上述方案，可显著提升MongoDB查询的准确性与执行效率。建议在复杂查询场景中结合explain()分析执行计划，持续优化索引策略。最后更新：2025年2月10日版权声明：本文采用CC BY-NC-SA 4.0协议，转载请注明出处
【踩坑日志】mybatis：Caused by: org.apache.ibatis.ognl.ParseException: Encountered " <IDENT> "AND "" at line
报错信息 Caused by: org.apache.ibatis.ognl.ParseException: Encountered " <IDENT> "AND "" at line 1, column 19. Was expecting one of: <EOF> "," ... "=" ... "?" ... "||" ... "or" ... "&&" ... "and" ... "|" ... "bor" ... "^" ... "xor" ... "&" ... "band" ... "==" ... "eq" ... "!=" ... "neq" ... "<" ... "lt" ... ">" ... "gt" ... "<=" ... "lte" ... ">=" ... "gte" ... "in" ... "not" ... "<<" ... "shl" ... ">>" ... "shr" ... ">>>" ... "ushr" ... "+" ... "-" ... "*" ... "/" ... "%" ... "instanceof" ... "." ... "(" ... "[" ... <DYNAMIC_SUBSCRIPT> ...报错原因在mybatis中<if test="companyId != null AND companyId != ''"> AND a.company_id=#{companyId} </if> <if test="room != null AND room != ''"> AND t_sys_room.NAME=#{room} </if> <if test="deviceModel != null AND deviceModel != ''"> AND t_sys_dict.label=#{deviceModel} </if>if标签里面的 and应该是小写，而不是大写。
我以前用的foreach一般是这样的<delete id="deleteByIds"> delete from tb_brand where id in <foreach collection="array" item="id" separator="," open="(" close=")"> #{id} </foreach> </delete>这条语句时没错的，我们使用open="(" close=")"，对最外层加上了括号。但是今天我使用mybatis写一个批量查询如下语句（模拟的案例）：<insert id="batchInsert" parameterType="java.util.List"> insert into twn_nms_app_fttx.t_branch_history_trend(id, kpi_utc_sec, sample_interval, location, active_devices, evt_devices, stream_devices, total_devices, http_bytes, dist_http_err_code, dist_video_type, dist_event, grn_devices, blue_devices, ylw_devices, red_devices) values <foreach collection="list" item="item" separator="," open="(" close=")"> null, #{item.kpiutCSec}, #{item.sampleInterval}, #{item.location}, #{item.activeDevices}, #{item.evtDevices}, #{item.streamDevices}, #{item.totalDevices}, #{item.httpBytes}, #{item.distHttpErrCode}, #{item.distVideoType}, #{item.distEvent}, #{item.grnDevices}, #{item.blueDevices}, #{item.ylwDevices}, #{item.redDevices} </foreach> </insert>结果就是，当插入一条时，能够成功运行，当插入多条时就会报错，看了十多分中没结果，去上厕所恍然大悟！！好几次都是去厕所想明白的😂这个问题可能是由于在的<foreach>标签中，使用了逗号，作为分隔符。当你的列表只有一条数据时，这不会产生问题，因为只有一个值的集合被插入，没有逗号。但是，当列表有多条数据时，每个值的集合之间会被逗号分隔，并且每一条数据没有括号，只会在总的数据两边加上括号，这可能会导致SQL语句的格式错误。所以正确的语句应该是：<insert id="batchInsert" parameterType="java.util.List"> insert into twn_nms_app_fttx.t_branch_history_trend(id, kpi_utc_sec, sample_interval, location, active_devices, evt_devices, stream_devices, total_devices, http_bytes, dist_http_err_code, dist_video_type, dist_event, grn_devices, blue_devices, ylw_devices, red_devices) values <foreach collection="list" item="item" separator=","> ( null, #{item.kpiutCSec}, #{item.sampleInterval}, #{item.location}, #{item.activeDevices}, #{item.evtDevices}, #{item.streamDevices}, #{item.totalDevices}, #{item.httpBytes}, #{item.distHttpErrCode}, #{item.distVideoType}, #{item.distEvent}, #{item.grnDevices}, #{item.blueDevices}, #{item.ylwDevices}, #{item.redDevices} ) </foreach> </insert>总结：想不明白时去厕所摸鱼玩玩手机。
【踩坑日志】TDengine在SpringBoot项目中使用order by ts desc limit 1出现错误
问题描述我这里是SpringBoot+Mybatis+TDengine项目，我想获取一个表中的最新数据于是有了这样一条SQL：select * from my_table_name order by ts desc limit 1但是它执行报错了### SQL: select * from tw_nms_report.stable_olt_statistics order by ts desc limit 1 ### Cause: java.sql.SQLException: Error ; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; Error; nested exception is java.sql.SQLException: Error at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) at com.sun.proxy.$Proxy127.selectOne(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:83)我发现当被查询的表中只有一条数据时，它能正确执行，不报错。但是表中的数据如果大于两条，那么他就会报上面的错误。项目结构Java实体类package com.tw.nms.report.td.entity; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; import javax.persistence.Column; import javax.persistence.Table; import java.io.Serializable; /** * @author wufan * @create 2023/10/24 * @Description Olt设备信息统计 */ @Data @EqualsAndHashCode(callSuper = false) @Table(name = "stable_olt_statistics", schema = "tw_nms_report") @ToString public class OltStatisticsTdEntity implements Serializable { // 序列化: 用于网络传输 private static final long serialVersionUID = 1L; // 时间戳 @Column(name = "ts") private String ts; // 设备总数：所有的设备数量 @Column(name = "allDevices") private Integer allDevices; // 在网设备数量：记录在网设备的数量 @Column(name = "onlineDevices") private Integer onlineDevices; // 在网设备占比：表示在网设备数量占总设备数量的比例 @Column(name = "onlineDeviceRatio") private Double onlineDeviceRatio; // 设备类型分布：记录各种设备类型的数量 @Column(name = "deviceTypeDistribution") private String deviceTypeDistribution; // 区域分布：记录各区域的设备数量 @Column(name = "areaDistribution") private String areaDistribution; }TDengine表结构CREATE TABLE IF NOT EXISTS sTable_olt_statistics ( ts TIMESTAMP, allDevices INT, onlineDevices INT, onlineDeviceRatio DOUBLE, deviceTypeDistribution BINARY(255), areaDistribution BINARY(255) ); Mapperpublic interface OltStatisticsTDMapper extends Mapper<OltStatisticsTdEntity> { OltStatisticsTdEntity getNewestOltStatistics(); }XML<?xml version="1.0" encoding="UTF-8" ?> <mapper namespace="com.tw.nms.report.td.mapper.OltStatisticsTDMapper"> select * from tw_nms_report.stable_olt_statistics order by ts desc limit 1 </mapper>解决方法使用last_row代替。select last_row(olts.ts) as ts, last_row(olts.allDevices) as allDevices, last_row(olts.onlineDevices) as onlineDevices, last_row(olts.onlineDeviceRatio) as onlineDeviceRatio, last_row(olts.deviceTypeDistribution) as deviceTypeDistribution, last_row(olts.areaDistribution) as areaDistribution from tw_nms_report.stable_olt_statistics as olts
在mybatis的Java文件中提示@MapKey is requiredJava/** * 查询各种设备类型的数量 * @return List<Map<String, Integer>> */ List<Map<String, Object>> GroupByDeviceTypeDistribution();xml select area, count(*) as count from `twn_nms_app_fttx`.`t_fttx_olt_statistics` group by area; 看似没有问题，但是对于返回的数据中Map的key是哪个字段你却没有指定，所以我们这里需要使用@MapKey注解，来指定指端作为Map的key。我们将Java代码修改为/** * 查询各种设备类型的数量 * @return List<Map<String, Integer>> */ @MapKey("area") List<Map<String, Object>> GroupByDeviceTypeDistribution();即可。
【踩坑日志】ServiceAuthFeign#getAllowedClient(String,String) failed and no fallback available.
报错信息Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 10:27:20.074 nms-admin-server [main] ERROR o.s.boot.SpringApplication - Application startup failed java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:735) at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:716) at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:703) at org.springframework.boot.SpringApplication.run(SpringApplication.java:304) at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) at com.tw.nms.admin.AdminBootstrap.main(AdminBootstrap.java:40) Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: ServiceAuthFeign#getAllowedClient(String,String) failed and no fallback available. at com.netflix.hystrix.AbstractCommand$22.call(AbstractCommand.java:819) at com.netflix.hystrix.AbstractCommand$22.call(AbstractCommand.java:804) at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:140) at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87) at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87) at com.netflix.hystrix.AbstractCommand$DeprecatedOnFallbackHookApplication$1.onError(AbstractCommand.java:1472) at com.netflix.hystrix.AbstractCommand$FallbackHookApplication$1.onError(AbstractCommand.java:1397) at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87) at rx.observers.Subscribers$5.onError(Subscribers.java:230) at rx.internal.operators.OnSubscribeThrow.call(OnSubscribeThrow.java:44) at rx.internal.operators.OnSubscribeThrow.call(OnSubscribeThrow.java:28) at rx.Observable.unsafeSubscribe(Observable.java:10211) at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51) at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) at rx.Observable.unsafeSubscribe(Observable.java:10211) at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.unsafeSubscribe(Observable.java:10211) at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) at rx.Observable.unsafeSubscribe(Observable.java:10211) at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.unsafeSubscribe(Observable.java:10211) at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.unsafeSubscribe(Observable.java:10211) at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:142) at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87) at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87) at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$2.onError(AbstractCommand.java:1194) at rx.internal.operators.OperatorSubscribeOn$1$1.onError(OperatorSubscribeOn.java:59) at rx.observers.Subscribers$5.onError(Subscribers.java:230) at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87) at rx.observers.Subscribers$5.onError(Subscribers.java:230) at com.netflix.hystrix.AbstractCommand$DeprecatedOnRunHookApplication$1.onError(AbstractCommand.java:1431) at com.netflix.hystrix.AbstractCommand$ExecutionHookApplication$1.onError(AbstractCommand.java:1362) at rx.observers.Subscribers$5.onError(Subscribers.java:230) at rx.observers.Subscribers$5.onError(Subscribers.java:230) at rx.internal.operators.OnSubscribeThrow.call(OnSubscribeThrow.java:44) at rx.internal.operators.OnSubscribeThrow.call(OnSubscribeThrow.java:28) at rx.Observable.unsafeSubscribe(Observable.java:10211) at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51) at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.unsafeSubscribe(Observable.java:10211) at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51) at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) at rx.Observable.unsafeSubscribe(Observable.java:10211) at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.unsafeSubscribe(Observable.java:10211) at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94) at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:56) at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:47) at org.springframework.cloud.sleuth.instrument.hystrix.SleuthHystrixConcurrencyStrategy$HystrixTraceCallable.call(SleuthHystrixConcurrencyStrategy.java:154) at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction.call(HystrixContexSchedulerAction.java:69) at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) 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:750) Caused by: java.lang.RuntimeException: com.netflix.client.ClientException: Load balancer does not have available server for client: nms-auth-center at org.springframework.cloud.netflix.feign.ribbon.LoadBalancerFeignClient.execute(LoadBalancerFeignClient.java:71) at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:97) at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76) at feign.hystrix.HystrixInvocationHandler$1.run(HystrixInvocationHandler.java:108) at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:302) at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:298) at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46) ... 27 common frames omitted Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: nms-auth-center at com.netflix.loadbalancer.LoadBalancerContext.getServerFromLoadBalancer(LoadBalancerContext.java:483) at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:184) at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:180) at rx.Observable.unsafeSubscribe(Observable.java:10211) at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:94) at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:42) at rx.Observable.unsafeSubscribe(Observable.java:10211) at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber$1.call(OperatorRetryWithPredicate.java:127) at rx.internal.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.enqueue(TrampolineScheduler.java:73) at rx.internal.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.schedule(TrampolineScheduler.java:52) at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber.onNext(OperatorRetryWithPredicate.java:79) at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber.onNext(OperatorRetryWithPredicate.java:45) at rx.internal.util.ScalarSynchronousObservable$WeakSingleProducer.request(ScalarSynchronousObservable.java:276) at rx.Subscriber.setProducer(Subscriber.java:209) at rx.internal.util.ScalarSynchronousObservable$JustOnSubscribe.call(ScalarSynchronousObservable.java:138) at rx.internal.util.ScalarSynchronousObservable$JustOnSubscribe.call(ScalarSynchronousObservable.java:129) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.subscribe(Observable.java:10307) at rx.Observable.subscribe(Observable.java:10274) at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:445) at rx.observables.BlockingObservable.single(BlockingObservable.java:342) at com.netflix.client.AbstractLoadBalancerAwareClient.executeWithLoadBalancer(AbstractLoadBalancerAwareClient.java:117) at org.springframework.cloud.netflix.feign.ribbon.LoadBalancerFeignClient.execute(LoadBalancerFeignClient.java:63) ... 33 common frames omitted 10:27:20.075 nms-admin-server [main] INFO o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5d465e4b: startup date [Fri Oct 20 10:27:07 CST 2023]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@10959ece 10:27:20.075 nms-admin-server [main] INFO o.s.c.n.e.s.EurekaServiceRegistry - Unregistering application nms-admin-center with eureka with status DOWN 10:27:20.075 nms-admin-server [main] WARN c.netflix.discovery.DiscoveryClient - Saw local status change event StatusChangeEvent [timestamp=1697768840075, current=DOWN, previous=UP] 10:27:20.075 nms-admin-server [main] INFO c.netflix.discovery.DiscoveryClient - Shutting down DiscoveryClient ... 10:27:20.076 nms-admin-server [DiscoveryClient-InstanceInfoReplicator-0] INFO c.netflix.discovery.DiscoveryClient - DiscoveryClient_NMS-ADMIN-CENTER/Fivk:nms-admin-center:8763: registering service... 10:27:20.076 nms-admin-server [main] INFO c.netflix.discovery.DiscoveryClient - Unregistering ... 10:27:20.080 nms-admin-server [main] INFO c.netflix.discovery.DiscoveryClient - DiscoveryClient_NMS-ADMIN-CENTER/Fivk:nms-admin-center:8763 - deregister status: 200 10:27:20.081 nms-admin-server [main] INFO c.netflix.discovery.DiscoveryClient - Completed shut down of DiscoveryClient 10:27:20.082 nms-admin-server [main] INFO o.s.c.s.DefaultLifecycleProcessor - Stopping beans in phase 2147483647 10:27:20.083 nms-admin-server [main] INFO o.s.c.s.DefaultLifecycleProcessor - Stopping beans in phase 0 10:27:20.083 nms-admin-server [main] INFO o.s.b.a.e.jmx.EndpointMBeanExporter - Unregistering JMX-exposed beans on shutdown 10:27:20.083 nms-admin-server [main] INFO o.s.b.a.e.jmx.EndpointMBeanExporter - Unregistering JMX-exposed beans 10:27:20.083 nms-admin-server [main] INFO o.s.j.e.a.AnnotationMBeanExporter - Unregistering JMX-exposed beans on shutdown 10:27:20.083 nms-admin-server [main] INFO o.s.j.e.a.AnnotationMBeanExporter - Unregistering JMX-exposed beans 10:27:20.086 nms-admin-server [main] INFO o.s.c.a.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@6d864c70: startup date [Fri Oct 20 10:27:19 CST 2023]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5d465e4b 10:27:20.086 nms-admin-server [main] WARN o.s.c.a.AnnotationConfigApplicationContext - Exception thrown from ApplicationListener handling ContextClosedEvent org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:216) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078) at org.springframework.context.event.ApplicationListenerMethodAdapter.getTargetBean(ApplicationListenerMethodAdapter.java:280) at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:250) at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:174) at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:137) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:399) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:991) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) at org.springframework.cloud.context.named.NamedContextFactory.destroy(NamedContextFactory.java:76) at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:272) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968) at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1006) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) at com.tw.nms.admin.AdminBootstrap.main(AdminBootstrap.java:40) 10:27:20.086 nms-admin-server [main] INFO c.n.u.c.ShutdownEnabledTimer - Shutdown hook removed for: NFLoadBalancer-PingTimer-nms-auth-center 10:27:20.088 nms-admin-server [main] INFO o.s.c.a.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@48c584c: startup date [Fri Oct 20 10:27:13 CST 2023]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5d465e4b 10:27:20.088 nms-admin-server [main] WARN o.s.c.a.AnnotationConfigApplicationContext - Exception thrown from ApplicationListener handling ContextClosedEvent org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:216) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078) at org.springframework.context.event.ApplicationListenerMethodAdapter.getTargetBean(ApplicationListenerMethodAdapter.java:280) at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:250) at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:174) at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:137) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:399) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:991) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) at org.springframework.cloud.context.named.NamedContextFactory.destroy(NamedContextFactory.java:76) at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:272) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968) at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1006) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) at com.tw.nms.admin.AdminBootstrap.main(AdminBootstrap.java:40) 10:27:20.089 nms-admin-server [main] INFO o.s.c.a.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@3efb863c: startup date [Fri Oct 20 10:27:11 CST 2023]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5d465e4b 10:27:20.089 nms-admin-server [main] WARN o.s.c.a.AnnotationConfigApplicationContext - Exception thrown from ApplicationListener handling ContextClosedEvent org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:216) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078) at org.springframework.context.event.ApplicationListenerMethodAdapter.getTargetBean(ApplicationListenerMethodAdapter.java:280) at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:250) at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:174) at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:137) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:399) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:991) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) at org.springframework.cloud.context.named.NamedContextFactory.destroy(NamedContextFactory.java:76) at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:272) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968) at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1006) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) at com.tw.nms.admin.AdminBootstrap.main(AdminBootstrap.java:40) 10:27:20.089 nms-admin-server [main] INFO o.s.c.a.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@6b6d8671: startup date [Fri Oct 20 10:27:12 CST 2023]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5d465e4b 10:27:20.089 nms-admin-server [main] WARN o.s.c.a.AnnotationConfigApplicationContext - Exception thrown from ApplicationListener handling ContextClosedEvent org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:216) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078) at org.springframework.context.event.ApplicationListenerMethodAdapter.getTargetBean(ApplicationListenerMethodAdapter.java:280) at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:250) at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:174) at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:137) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:399) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:991) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) at org.springframework.cloud.context.named.NamedContextFactory.destroy(NamedContextFactory.java:76) at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:272) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968) at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1006) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) at com.tw.nms.admin.AdminBootstrap.main(AdminBootstrap.java:40) 10:27:20.089 nms-admin-server [main] INFO o.s.c.a.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@31b7112d: startup date [Fri Oct 20 10:27:11 CST 2023]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5d465e4b 10:27:20.089 nms-admin-server [main] WARN o.s.c.a.AnnotationConfigApplicationContext - Exception thrown from ApplicationListener handling ContextClosedEvent org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:216) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078) at org.springframework.context.event.ApplicationListenerMethodAdapter.getTargetBean(ApplicationListenerMethodAdapter.java:280) at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:250) at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:174) at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:137) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:399) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:991) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) at org.springframework.cloud.context.named.NamedContextFactory.destroy(NamedContextFactory.java:76) at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:272) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968) at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1006) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) at com.tw.nms.admin.AdminBootstrap.main(AdminBootstrap.java:40) 10:27:20.095 nms-admin-server [DiscoveryClient-InstanceInfoReplicator-0] INFO c.netflix.discovery.DiscoveryClient - DiscoveryClient_NMS-ADMIN-CENTER/Fivk:nms-admin-center:8763 - registration status: 204 10:27:20.135 nms-admin-server [Thread-36] INFO c.n.l.PollingServerListUpdater - Shutting down the Executor Pool for PollingServerListUpdater 进程已结束，退出代码为 1报错原因可以看主要信息ServiceAuthFeign#getAllowedClient(String,String) failed and no fallback available.这个的意思就是Feign调用远程出现问题，最后发现是eureka注册中心对应的服务没有启动。
今天学到vue3，使用vite构建。但是我使用npm run dev运行时就会报错X [ERROR] Unexpected end of file in JSON ../package.json:1:0: 1 │ ╵ ^ failed to load config from E:\VsCodeProject\study_vue\vue3_test\vite.config.js error when starting dev server: Error: Build failed with 1 error: ../package.json:1:0: ERROR: Unexpected end of file in JSON at failureErrorWithLog (E:\VsCodeProject\study_vue\vue3_test\node_modules\esbuild\lib\main.js:1636:15) at E:\VsCodeProject\study_vue\vue3_test\node_modules\esbuild\lib\main.js:1048:25 at runOnEndCallbacks (E:\VsCodeProject\study_vue\vue3_test\node_modules\esbuild\lib\main.js:1471:45) at buildResponseToResult (E:\VsCodeProject\study_vue\vue3_test\node_modules\esbuild\lib\main.js:1046:7) at E:\VsCodeProject\study_vue\vue3_test\node_modules\esbuild\lib\main.js:1075:16 at responseCallbacks.<computed> (E:\VsCodeProject\study_vue\vue3_test\node_modules\esbuild\lib\main.js:697:9) at handleIncomingPacket (E:\VsCodeProject\study_vue\vue3_test\node_modules\esbuild\lib\main.js:752:9) at Socket.readFromStdout (E:\VsCodeProject\study_vue\vue3_test\node_modules\esbuild\lib\main.js:673:7) at Socket.emit (node:events:513:28) at addChunk (node:internal/streams/readable:324:12)或者\ Pre-bundling them to speed up dev server page load... (this will be run only when your dependencies have changed) [vite] Error loading postcss config:server page load... SyntaxError: E:\VsCodeProject\study_vue\package.json: Unexpected end of JSON input at parse (<anonymous>) at Module._extensions..json (node:internal/modules/cjs/loader:1322:39) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Module.require (node:internal/modules/cjs/loader:1141:19) at require (node:internal/modules/cjs/helpers:110:18) at Object.search (E:\VsCodeProject\study_vue\vue3_test\node_modules\lilconfig\dist\index.js:112:39) at async loadPostcssConfig (E:\VsCodeProject\study_vue\vue3_test\node_modules\vite\dist\node\utils\cssUtils.js:107:39) at async Object.resolvePostcssOptions (E:\VsCodeProject\study_vue\vue3_test\node_modules\vite\dist\node\utils\cssU报错原因我在E:\VsCodeProject\study_vue目录下新建的vue3_test。但是该目录下有package.json，会影响子目录的配置文件，所以一直启动不了。在其他目录下新建即可。
【踩坑日志】宝塔设置又拍云备份数据
这个坑踩过两次，就是设置操作员密码的时候，生成之后要点保存。
【踩坑日志】java.lang.Exception: No runnable methods
报错信息java.lang.Exception: No runnable methods at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:191) at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:128) at org.junit.runners.ParentRunner.validate(ParentRunner.java:416) at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84) at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:137) at org.springframework.test.context.junit4.SpringRunner.<init>(SpringRunner.java:49) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104) at org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder$DefensiveAnnotatedBuilder.buildRunner(DefensiveAllDefaultPossibilitiesBuilder.java:114) at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26) at org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder.runnerForClass(DefensiveAllDefaultPossibilitiesBuilder.java:57) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.vintage.engine.discovery.ClassSelectorResolver.resolveTestClass(ClassSelectorResolver.java:66) at org.junit.vintage.engine.discovery.ClassSelectorResolver.resolve(ClassSelectorResolver.java:47) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:134) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1361) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:185) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:125) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.access$100(EngineDiscoveryRequestResolution.java:57) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution$DefaultContext.resolve(EngineDiscoveryRequestResolution.java:224) at org.junit.vintage.engine.discovery.MethodSelectorResolver.resolveParentAndAddFilter(MethodSelectorResolver.java:56) at org.junit.vintage.engine.discovery.MethodSelectorResolver.resolve(MethodSelectorResolver.java:40) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:146) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1361) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:185) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:125) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:91) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:82) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.resolve(EngineDiscoveryRequestResolver.java:113) at org.junit.vintage.engine.discovery.VintageDiscoverer.discover(VintageDiscoverer.java:44) at org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:63) at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:181) at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:168) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)解决方法测试启动的注解是：@RunWith(SpringRunner.class) @SpringBootTest(classes = 启动类Application.class)@Test 注解的引用错了，应该是： import org.junit.Test;
报错信息java.lang.NullPointerException: null at cn.fivk.takeaway.controller.DishController.lambda$page$0(DishController.java:84) ~[classes/:na] at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[na:1.8.0_321] at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384) ~[na:1.8.0_321] at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[na:1.8.0_321] at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[na:1.8.0_321] at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_321] at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_321] at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_321] at cn.fivk.takeaway.controller.DishController.page(DishController.java:88) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_321] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_321] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_321] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_321] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.20.jar:5.3.20] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.20.jar:5.3.20] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.20.jar:5.3.20] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.20.jar:5.3.20] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.20.jar:5.3.20] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.20.jar:5.3.20] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.20.jar:5.3.20] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.20.jar:5.3.20] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.20.jar:5.3.20] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.20.jar:5.3.20] at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) ~[tomcat-embed-core-9.0.63.jar:4.0.FR] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.20.jar:5.3.20] at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.63.jar:4.0.FR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.63.jar:9.0.63] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at cn.fivk.takeaway.filter.LoginCheckFilter.doFilter(LoginCheckFilter.java:72) ~[classes/:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.20.jar:5.3.20] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.20.jar:5.3.20] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.63.jar:9.0.63] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.63.jar:9.0.63] at java.lang.Thread.run(Thread.java:750) [na:1.8.0_321]解决方法发现是注入的service没有加上@Autowired注解。