Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Gradle的spring bootRun和Angular buildWatch_Angular_Spring Boot_Gradle_Build_Watch - Fatal编程技术网

使用Gradle的spring bootRun和Angular buildWatch

使用Gradle的spring bootRun和Angular buildWatch,angular,spring-boot,gradle,build,watch,Angular,Spring Boot,Gradle,Build,Watch,我想在spring boot多模块应用程序中使用angular 4作为客户端框架。 我的应用程序包含3个模块 域模块 服务模块 web模块(弹簧引导模块) angular 4根目录位于web模块内 我可以使用“ng build”命令启动bootRun来执行应用程序(它编译angular typescript文件并复制springBoot静态资源目录中的结果文件) 这项工作是你的(顺便说一句,感谢乌梅什·穆尔苏的出色指导) 下面是我使用的gradle脚本: task buildClientDev(

我想在spring boot多模块应用程序中使用angular 4作为客户端框架。 我的应用程序包含3个模块

  • 域模块
  • 服务模块
  • web模块(弹簧引导模块)
  • angular 4根目录位于web模块内

    我可以使用“ng build”命令启动bootRun来执行应用程序(它编译angular typescript文件并复制springBoot静态资源目录中的结果文件) 这项工作是你的(顺便说一句,感谢乌梅什·穆尔苏的出色指导)

    下面是我使用的gradle脚本:

    task buildClientDev(type: NpmTask, dependsOn: 'npmInstall') {
                group = 'build'
                description = 'Compile client side folder for development'
                args = ['run','buildDev']
            }
    
    
    task buildClientWatch(type: NpmTask, dependsOn: 'npmInstall'){
                group = 'application'
                description = "Build and watches the client side assets for rebuilding"
                args = ['run','buildWatch']
    }
    
    bootRun{
        doFirst {
            tasks.buildClientDev.execute()
        }
    }
    

    这样做的问题是,当我修改TypeScript文件(生成js文件)时,我必须重新运行bootRun。我希望这一代能够自动完成。所以我想调用
    tasks.buildClientWatch.execute()
    ,它执行一个“
    ng build watch=true
    ”。但当我这样做时,springBoot应用程序无法启动。 当我使用
    doLast
    而不是
    doFirst
    时,我的Springboot应用程序启动得很好,但是doLast中的gradle调用都没有执行


    那么,如何同时运行springBoot bootRun命令和do
    ng build watch=true
    呢?

    我建议直接使用npm而不使用Gradle(因为我这样做没有任何问题)。大多数IDE也以组合构建/发布组的方式支持这一点。

    在使用angular开发应用程序3年后,我认为在这种情况下最好的做法是完全分离前端和后端

    所以我可以为我的angular frontend应用程序创建npm或gradle项目。 对于后端,我可以创建我喜欢的微服务和模块。
    我认为这是目前最好的模式。

    “springBoot应用程序无法启动”-为什么?