Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/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
Spring boot 使用Spring Boot和wro4j在IntelliJ中进行热插拔_Spring Boot_Wro4j - Fatal编程技术网

Spring boot 使用Spring Boot和wro4j在IntelliJ中进行热插拔

Spring boot 使用Spring Boot和wro4j在IntelliJ中进行热插拔,spring-boot,wro4j,Spring Boot,Wro4j,我目前正在使用AngularJs为嵌入式服务器(打包在.jar文件中,以Tomcat运行)开发前端/webapp。服务器有一些API端点,我希望能够在前端使用这些端点 我目前的方法是使用webjars加载我选择的angularjs版本,然后在webapp文件夹中构建应用程序。结构如下: ├───src │ ├───main │ │ ├───docker │ │ ├───java │ │ │ └───com │ │ │ └───... │

我目前正在使用AngularJs为嵌入式服务器(打包在.jar文件中,以Tomcat运行)开发前端/webapp。服务器有一些API端点,我希望能够在前端使用这些端点

我目前的方法是使用webjars加载我选择的angularjs版本,然后在webapp文件夹中构建应用程序。结构如下:

├───src
│   ├───main
│   │   ├───docker
│   │   ├───java
│   │   │   └───com
│   │   │       └───...    
│   │   ├───resources
│   │   └───webapp
│   │       └───public
│   │           ├───css
│   │           └───js
│   │               └───controllers
└───target
    ├───classes
    │   ├───com
    │   │   └───... 
    │   └───public
    │       ├───css
    │       └───js
    │           └───controllers
    ├───generated-sources
    │   └───annotations
    ├───generated-test-sources
    │   └───test-annotations
    └───test-classes
        └───com
            └───...
我正在编辑的文件位于src/main/webapp/public文件夹中,它们正在“编译”到target/classes/public文件夹中。 如果我想在服务器运行时重新加载一个文件,我必须执行
Run->reload Changed class
,这在开发过程中非常有效

但由于我最初来自“独立”AngularJs开发,我已经习惯于使用真正的livereload和一个构建链来缩小和连接js/css文件以进行优化(grunt,bower)

现在我已经研究了wro4j,并且能够很好地设置它。对我来说,还有一件事我仍然不知道,那就是热的重新加载。甚至上述方法也不再适用于wro4j,因此唯一的选择是重新编译整个应用程序,以查看css/javascript或HTML内部的更改。 有没有简单的办法

我的首选方法是在开发时处理未统一/未连接的版本(在调试中运行服务器),并且仅在部署应用程序(或仅运行应用程序)时执行整个构建链


我的选择是什么?

查看Spring Boot DevTools文档

Maven.

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

它包括一个内置的LiveReload服务器。您应该可以通过运行“Make Project”从IntelliJ更新您的应用程序。

我最后所做的可能有点过火,但我没有找到任何其他合适的解决方案

我构建了一个Gruntfile.js(基于angularjs的yeoman生成器),以便能够拥有livereload和构建链功能(concat、minify等)。有了这个,我也可以在前端工作,而不必启动服务器。该文件中唯一的“恶意攻击”是
grunt build
将其dist文件夹复制到
/src/main/resources/static
文件夹,以便将其“编译”到.war文件中

我使用了一些maven插件,以便能够在构建时执行所需的命令(npm安装、bower安装、grunt构建、grunt清理)


com.github.eirslett
前端maven插件
0.0.22 
org.codehaus.plexus
尾丛
2.1
v0.10.18
1.3.8
src/主/前端
安装节点和npm
安装节点和npm
产生资源
npm安装
npm
安装
凉亭安装
凉亭
安装
npm重建
npm
重建节点sass
咕噜声
咕哝
建造
清洁前安装npm
npm
清洁的
安装
干净利落
咕哝
清洁的
清洁的

我希望这能为我的方法提供一个大致的思路。这当然不是完美的,特别是因为它增加了整个项目的构建时间。

不,Spring开发工具livereload不会检测到IntelliJ中使用wro4j对静态内容所做的更改。此外,在wro4j配置中启用缓存时,它甚至不会更新生成的捆绑包js或css。这对我来说很有效:
dependencies {
    compile("org.springframework.boot:spring-boot-devtools")
}
<plugin>
 <groupId>com.github.eirslett</groupId>
 <artifactId>frontend-maven-plugin</artifactId>
 <version>0.0.22</version> <!-- last version supported by maven 2 -->
 <dependencies>
     <dependency>
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-utils</artifactId>
         <version>2.1</version>
     </dependency>
 </dependencies>
 <configuration>
     <nodeVersion>v0.10.18</nodeVersion>
     <npmVersion>1.3.8</npmVersion>
     <workingDirectory>src/main/frontend</workingDirectory>
 </configuration>
 <executions>
     <execution>
         <id>install node and npm</id>
         <goals>
             <goal>install-node-and-npm</goal>
         </goals>
         <phase>generate-resources</phase>
     </execution>
     <execution>
         <id>npm install</id>
         <goals>
             <goal>npm</goal>
         </goals>

         <configuration>
             <arguments>install</arguments>
         </configuration>
     </execution>
     <execution>
         <id>bower install</id>
         <goals>
             <goal>bower</goal>
         </goals>

         <configuration>
             <arguments>install</arguments>
         </configuration>
     </execution>
     <execution>
         <id>npm rebuild</id>
         <goals>
             <goal>npm</goal>
         </goals>

         <configuration>
             <arguments>rebuild node-sass</arguments>
         </configuration>
     </execution>
     <execution>
         <id>grunt build</id>
         <goals>
             <goal>grunt</goal>
         </goals>

         <configuration>
             <arguments>build</arguments>
         </configuration>
     </execution>
     <execution>
         <id>npm install before clean</id>
         <goals>
             <goal>npm</goal>
         </goals>

         <phase>clean</phase>

         <configuration>
             <arguments>install</arguments>
         </configuration>
     </execution>
     <execution>
         <id>grunt clean</id>
         <goals>
             <goal>grunt</goal>
         </goals>

         <phase>clean</phase>

         <configuration>
             <arguments>clean</arguments>
         </configuration>
     </execution>
 </executions>
</plugin>