【问题标题】:Building a SpringBoot 2.0.5.RELEASE + Angular 5 +Spring Data + Rest project构建一个 SpringBoot 2.0.5.RELEASE + Angular 5 +Spring Data + Rest 项目
【发布时间】:2019-03-09 21:33:44
【问题描述】:

我是 Angular 方面的新手,我创建了一个项目,使用 SpringBoot 2.0.5.RELEASE、Angular 5 和 spring data 来构建端到端单页 Java Web 应用程序。我使用 spring boot 1.5 来公开 REST API,并使用 angular5 来构建客户端,该客户端将使用服务器公开的 API

我刚刚建立了一个项目来使用 SpringBoot 2.0.5.RELEASE。 当我这样做时:

$ ng -v
    Your global Angular CLI version (6.2.4) is greater than your local
    version (6.2.3). The local Angular CLI version is used.

    To disable this warning use "ng config -g cli.warnings.versionMismatch false".

         _                      _                 ____ _     ___
        / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
       / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
      / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
     /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                    |___/


    Angular CLI: 6.2.3
    Node: 10.11.0
    OS: darwin x64
    Angular: 5.1.3
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router

    Package                      Version
    ------------------------------------------------------
    @angular-devkit/architect    0.8.3
    @angular-devkit/core         0.8.3
    @angular-devkit/schematics   0.8.3
    @angular/cli                 6.2.3
    @schematics/angular          0.8.3
    @schematics/update           0.8.3
    rxjs                         5.5.6
    typescript                   2.4.2

一切似乎都很好。

那我做

$ npm install
audited 11048 packages in 3.985s
found 0 vulnerabilities

一切似乎都很好。

但是当我这样做时

$ ng build
Your global Angular CLI version (6.2.4) is greater than your local
version (6.2.3). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
Local workspace file ('angular.json') could not be found.
Error: Local workspace file ('angular.json') could not be found.
    at WorkspaceLoader._getProjectWorkspaceFilePath (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/models/workspace-loader.js:44:19)
    at WorkspaceLoader.loadWorkspace (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/models/workspace-loader.js:31:21)
    at BuildCommand._loadWorkspaceAndArchitect (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/models/architect-command.js:201:32)
    at BuildCommand.<anonymous> (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/models/architect-command.js:53:25)
    at Generator.next (<anonymous>)
    at /Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/models/architect-command.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/models/architect-command.js:3:12)
    at BuildCommand.initialize (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/models/architect-command.js:52:16)
    at Object.<anonymous> (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/models/command-runner.js:127:23)

我尝试使用以下方式更新项目:

npm install -g @angular-devkit/core
npm install -g @angular/cli
npm install @angular/cli

但是当我跑步时

ng update @angular/cli
Workspace needs to be loaded before it is used.
Error: Workspace needs to be loaded before it is used.
    at Workspace._assertLoaded (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular-devkit/core/src/workspace/workspace.js:68:19)
    at Workspace.getProjectByPath (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular-devkit/core/src/workspace/workspace.js:116:14)
    at getProjectByCwd (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/utilities/config.js:103:26)
    at Object.getPackageManager (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/utilities/config.js:115:25)
    at UpdateCommand.getWorkflow (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/models/schematic-command.js:105:38)
    at UpdateCommand._getWorkflow (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/models/schematic-command.js:111:35)
    at UpdateCommand.runSchematic (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/models/schematic-command.js:121:31)
    at UpdateCommand.<anonymous> (/Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/commands/update-impl.js:76:25)
    at Generator.next (<anonymous>)
    at /Users/nunet/Development/J2EE/eclipseWSJ2EE/portal-app/node_modules/@angular/cli/commands/update-impl.js:14:71

【问题讨论】:

  • 看起来您的项目是使用 Angular CLI 6.2.3 生成的,但您的 6.2.4 正在全局运行。此外,您当前在其中运行ng build 命令的文件夹中没有angular.json 文件。确保您在正确的文件夹中构建,并且您没有以某种方式删除它。也许您必须向我们展示您的项目结构。
  • 可能是因为我拿了一个示例项目并安装了最新版本的 Angular CLI
  • 我从这里拿它,我也看不到文件 angular.json:github.com/only2dhir/spring-boot-angular5/tree/master/…
  • 嗯,该项目是使用 Angular CLI 1.6.3 生成的,如 README.md 所述。所以,是的,如果不迁移它,这个设置将不起作用。 Angular Update Guide 可能会有所帮助,但现在看起来您并未正确迁移项目以使用 Angular CLI 6.x.x。

标签: node.js angular spring-boot


【解决方案1】:

您需要将 .angular-cli.json 转换为 angular.json。详情请参考this

【讨论】:

    猜你喜欢
    • 2019-02-26
    • 2015-03-23
    • 2016-08-16
    • 1970-01-01
    • 2019-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-25
    相关资源
    最近更新 更多