简体   繁体   English

如何在 Jhipster 中配置热重载?

[英]How to configure hot reload in Jhipster?

I am using Jhipster(Angular + Springboot) Application for my existing project.我正在为我现有的项目使用 Jhipster(Angular + Springboot)应用程序。

I managed to create a controller(app.resource) manually apart from the ones already generated by jhiptser(using .jh file) for achieving a file download functionality.除了 jhiptser 已经生成的控制器(使用 .jh 文件)之外,我设法手动创建了一个控制器(app.resource)以实现文件下载功能。

So, when we start the server we usually initiate two servers ie gradlew and npm start .所以,当我们启动服务器时,我们通常会启动两个服务器,即gradlewnpm start The second runs on port 9000 which eventually supports hot reload functionality.(front-end development)第二个运行在端口 9000 上,最终支持热重载功能。(前端开发)

So the problem is, I am able to access those endpoints from the server running on standard 8000 port.所以问题是,我能够从运行在标准 8000 端口上的服务器访问这些端点。 However, from the port which is a proxy(9000), the method is returning 404.但是,从代理端口(9000),该方法返回 404。

I tried to clean build the application several times.我多次尝试清理构建应用程序。

NOTE: The @RequestMapping value on the new controller is different then those present already.注意:新控制器上的@RequestMapping值与已经存在的值不同。

Does this have to do something with spring security?这是否与弹簧安全有关?

Thanks in advance.提前致谢。

Here is the previous controller:这是之前的控制器:

@RestController
@RequestMapping("/api")
public class FGAppDiagramResource {
@GetMapping(value = "/fg-app-diagram-downloadFile")
    public void getImage(String fileName,String folderName, HttpServletResponse 
    response){
    // Some Code
}
}

Here is my New controller:这是我的新控制器:

@RestController
@RequestMapping("/fileDownload")
public class DownloadFileController {

private final Logger log = 
LoggerFactory.getLogger(DownloadFileController.class);


public DownloadFileController() {
    super();
}

@Autowired
private ApplicationProperties applicationProperties; 

@GetMapping(value = "/fg-app-diagram-downloadFile/{fileName}/{folderName}")
public void getImage(@PathVariable String fileName,@PathVariable String folderName, HttpServletResponse response) {
// Some Code
}
}

Your new controller does not use /api so you must add your endpoint URL /fileDownload to proxy configuration of webpack dev server in webpack/webpack.dev.js您的新控制器不使用/api因此您必须将端点 URL /fileDownload添加到webpack/webpack.dev.js中 webpack 开发服务器的代理配置

    proxy: [{
        context: [
            /* jhipster-needle-add-entity-to-webpack - JHipster will add entity api paths here */
            '/api',
            '/fileDownload',

You may want to use /api/fileDownload to avoid changing proxy configuration and also because /api is useful for many other aspects like security and also using HTML5 URL routing strategy in Angular to get rid of # in client routes (see https://github.com/jhipster/generator-jhipster/pull/9098 ).您可能希望使用/api/fileDownload来避免更改代理配置,还因为/api对于许多其他方面(如安全性)以及在 Angular 中使用 HTML5 URL 路由策略来摆脱客户端路由中的#都很有用(请参阅https:// github.com/jhipster/generator-jhipster/pull/9098 )。

/api and /management are namespaces to avoid route conflicts, so it is usually wise to use them for your new endpoints. /api/management是避免路由冲突的命名空间,因此将它们用于新端点通常是明智的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM