简体   繁体   English

启动应用程序Spring MVC + Grunt + JHipster + AngularJS时出现问题

[英]Issue with starting application Spring MVC + Grunt + JHipster + AngularJS

I am using Spring MVC in my RESTful web aplication that I run using Maven . 我在使用Maven运行的RESTful Web应用程序中使用Spring MVC I have two profiles: 我有两个配置文件:

  1. Development profile, which works properly on hsql and oracle. 开发配置文件,可在hsql和oracle上正常工作。 I successfully build my application, and it works great. 我成功构建了我的应用程序,并且运行良好。

  2. Production profile, where I am using Grunt Javascript Task runner, for minification Javascript, CSS and HTML files. 生产概要文件,我在其中使用Grunt Javascript任务运行程序,用于压缩Javascript,CSS和HTML文件。

When I run my application in "prod" profile, Maven is building my application using Grunt . 当我在“产品”配置文件中运行应用程序时, Maven正在使用Grunt构建应用程序。 Grunt does his job properly, he change my files based on configuration in Gruntfile.js . Grunt可以正常工作,他根据Gruntfile.js中的配置更改了我的文件。 Files are changed properly and saved in dist folder, and new index.html file is created with references to newly generated CSS and Javascript files. 正确更改文件并将其保存在dist文件夹中,并使用对新生成的CSSJavascript文件的引用来创建新的index.html文件。 I build my app successfully. 我成功构建了我的应用程序。

The problem is, when I start my app on http://localhost:8080 , I only load css and javascript files from dist folder and make call GET login , but I am stuck here (using Firebug in Firefox browser): 问题是,当我在http:// localhost:8080上启动我的应用程序时,我仅从dist文件夹加载cssjavascript文件并进行调用GET login ,但是我被卡在这里(在Firefox浏览器中使用Firebug):

在此处输入图片说明

Not one REST call is made to my application. 我的应用程序没有一个REST调用。 When I start application in working dev profile, first call is for rest/authenticate , but in prod profile, I never gets there. 当我在可用的开发人员配置文件中启动应用程序时,第一个调用是rest / authenticate ,但是在产品概要文件中,我从未到达那里。 When I turn on logs for spring framework, I can see that my AntPathRequestMatcher gets stuck after checking my favicon.ico, and never gets to rest/authenticate . 当我打开spring框架的日志时,可以看到我的AntPathRequestMatcher在检查了我的favicon.ico之后卡住了,并且从不休息/认证 It seams like my javascript code is not initialized properly so he can make REST calls?! 好像我的JavaScript代码未正确初始化,因此他可以进行REST调用吗?!

I think I made my configuration properly in my WebConfigrurer.java , SecurityConfiguration.java , DispatcherServletConfiguration.java ... But I can't resolve this issue. 我想我已经在WebConfigrurer.javaSecurityConfiguration.javaDispatcherServletConfiguration.java中正确地进行了配置...但是我无法解决此问题。

If anyone had a similar problem, I would appreciate if he/she helps me. 如果有人遇到类似的问题,请多多关照。 Thanks. 谢谢。

Yes, it sounds like your javascript isn't running. 是的,听起来您的JavaScript没有运行。 Any errors in the firebug console? Firebug控制台有任何错误?

Obviously, the size of the script.js is 0 bytes?! 显然,script.js的大小是0个字节? Did you checked the content? 您检查内容了吗?

May be, it's possible that your scripts are not between (I assume you are using Jhipster v1.XX because you have script.js instead of app.js and vendor.js...) 可能是,您的脚本不在中间(我假设您使用的是Jhipster v1.XX,因为您使用的是script.js而不是app.js和vendor.js ...)

    <!-- build:js scripts/scripts.js -->

and

     <!-- endbuild -->

?

Grunt only packages all scripts that are between these two tags Grunt仅打包这两个标签之间的所有脚本

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

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