无法通过下列语句导入这个服务:

import {UserAuthenticationTokenService} from '@spartacus/core/src/auth/services/user-authentication/user-authentication-token.service';

解决办法:

While it’s true that it’s not being exported directly in Spartacus 2.x, I have found that it is still available. If you look at the compiled spartacus-core.d.ts file, you will see that UserAuthenticationTokenService is being exported under a gibberish(莫名其妙的) name:

export { UserAuthenticationTokenService as ɵbj } from './src/auth/services/user-authentication/user-authentication-token.service';

While this is probably not the best idea, I have found that you can actually import this in your own code. You can also rename it back to the original name for legibility:

import { ɵbj as UserAuthenticationTokenService } from '@spartacus/core';

I have used this myself on my current project and it seems to work fine:

@Injectable({providedIn: 'root'
})
export class MyUserAuthenticationTokenService extends UserAuthenticationTokenService {}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MyUserAuthenticationTokenService } from './services/my-user-authentication-token.service';
import { ɵbj as UserAuthenticationTokenService } from '@spartacus/core';@NgModule({declarations: [],imports: [CommonModule,],providers: [{ provide: UserAuthenticationTokenService, useExisting: MyUserAuthenticationTokenService }]
})
export class MyAuthModule {}
  • If you’re using Spartacus 2.x, UserAuthenticationTokenService is present in @spartacus/core, but unfortunately it doesn’t seem to be exposed in the public api. Therefore, you won’t be able to import it.

  • If you’re using Spartacus 3.x, UserAuthenticationTokenService was removed. Spartacus 3.0 introduces a new session management implementation. You can learn more about it here.

关于SAP Spartacus重载(override)UserAuthenticationTokenService的问题相关推荐

  1. SAP Spartacus 3.0 的一些变化

    SAP Spartacus 确实使用到了Bootstrap这个框架: Technical Changes in Spartacus 3.0 Breaking Changes Translations ...

  2. SAP Spartacus 4.0 版本因为 hamburger 依赖导致构建出错的问题

    build from Schematics 遇到错误消息: SassError: Undefined function. https://github.com/SAP/spartacus/issues ...

  3. SAP Spartacus UI 服务器端渲染的调试启动方式 - debug 模式

    首先确认你已经熟悉这篇文章的启动方式:SAP Spartacus develop branch 的服务器端渲染启动方式. 第一步 添加一个新的 build script,把 --configurati ...

  4. SAP Spartacus Session affinity

    参见这个讨论. 后端运行在多个 pods/节点时,当子序列请求过早进入时,后端将无法跨集群发送缓存失效请求.此外,如果多个请求分散在多个节点上,则会消耗延迟和不必要的资源. 对于单个客户端,Spart ...

  5. SAP Spartacus 4.0 的技术变化

    在您迁移到 4.0 版库之前,我们强烈建议您切换到新的应用程序结构和新的功能库. 在多个小步骤中进行迁移更容易(迁移到新的应用程序结构,切换到提取的功能库,然后迁移到 4.0),您可以确保在每一步之后 ...

  6. SAP Spartacus travis ci-scripts 下面 e2e-cypress.sh 的实现分析

    文件地址:https://github.com/SAP/spartacus/blob/develop/.travis.yml 里面引用到了 e2e-cypress.sh: https://github ...

  7. SAP Spartacus 里的 .release-it.json 文件

    在 SAP Spartacus package.json 里有一个依赖叫做 release-it: 这个工具的链接:https://github.com/release-it/release-it 这 ...

  8. SAP Spartacus PageLayoutComponent 如何知道自己应该显示哪些具体内容

    我们以前介绍过,经过 SAP Spartacus 路由配置后的 routes 数组,其 route 数据结构的 Component 属性,清一色指向 generic 的 PageLayoutCompo ...

  9. SAP Spartacus UI Duplicated keys has been found in the config of i18n chunks

    在测试 SAP Spartacus 3.4.5 版本的 SSR 功能时,发现一个 warning 信息: console.warn(`Duplicated keys has been found in ...

最新文章

  1. Codeforces Round #649 (Div. 2)C. Ehab and Prefix MEXs[排列的构造]
  2. 导出Windows服务器下的Oracle数据库并导入到Linux服务器下的Oracle数据库中
  3. 浅析移动端建站周期影响因素有哪些?
  4. JMeter性能测试的基础知识和个人理解
  5. JavaScript实现Floyd-Warshall算法(附完整源码)
  6. SpringBoot 中 @Transactional 的使用
  7. 今天安家 明天开始在网络的海洋里遨游
  8. Atitit.计算机图形图像图片处理原理与概论attilax总结
  9. iOs LightBlue与cc2540 BLE开发板之间的通信实验 [原创, 多图]
  10. c++ 远程监控软件
  11. 蓝天准系统P750的介绍与开箱
  12. FreeSWITCH ODBC cdr
  13. 数据库mysql表常见字段大小_常用数据库的字段类型及大小
  14. 基于MATLAB的光纤通信仿真
  15. Linux Thermal Framework分析及实施
  16. Android开发5年,字节腾讯惨被血虐,我真的不适合这行吗?
  17. Oracle_登录数据库系统
  18. web4.0之万能密码登录
  19. C51学习笔记 4.定时器
  20. Python psutil cpu_percent调用说明

热门文章

  1. 解决pl/sql devloper 中数据库操作语句中文乱码的问题
  2. 快速看完整部教材,列出你不懂的 5 - 10 个问题
  3. 一、spring mvc简介
  4. .NET各版本一览表
  5. 8086PC读取和执行指令相关部件
  6. 【转载】jQuery学习笔记
  7. string replace
  8. 展望Silverlight 5.0新版本更新与发展
  9. Contracts for Java
  10. V星入侵(V 2009)第一季全集下载