无法使用Bower安装的文件在Eclipse中工作 [英] Can't Get Files Installed with Bower to Work in Eclipse

查看:447
本文介绍了无法使用Bower安装的文件在Eclipse中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中创建了一个新的动态Web项目,在全局安装了 Bower ,然后在我的项目的根目录中本地安装,然后点击命令 bower install jquery 。它在我的项目中创建了一个 bower_components 文件夹,并完美添加了jquery文件夹。



这是创建的结构: / p>



然后,我创建了一个新的 index.html 文件,并试图引用 jquery 文件安装与 Bower [我没有修改任何构建路径或任何东西,我实际上是Eclipse的新手]。参考代码是:

 < head> 
< script src =bower_components / jquery / src / jquery.jstype =text / javascript>< / script>
< / head>

当我运行该页面;查看开发人员工具我不断收到错误:

  GET http:// localhost:8080 / PolymerTrials / bower_components / jquery / src / jquery.js 404(找不到)

当我复制浏览器中的URL并按Enter我得到:





我试图在我的目录中手动添加一个名为 jquery.js 的新文件,并复制粘贴jquery代码,它设法正确加载它。但是,任何使用 Bower 添加的文件,即使我确保引用的路径是正确的,也不会被加载。再次,我实际上是Eclipse和Bower以及所有这些东西的新手,所以希望你能帮忙。我觉得这不是包含在构建中。任何帮助是赞赏。谢谢!

解决方案

看起来你的文件没有被eclipse部署。



要修复此问题,请转到项目属性对话框中的部署程序集页面。在那里,您可以看到将由eclipse及其目的地部署的本地资源列表。如果您在其中添加bower_components文件夹,并将其部署路径设置为/ bower,则可以通过路径bower / jquery / src / jquery.js引用您的jQuery


I created a new "dynamic web project" in Eclipse, installed Bower globally and then locally in the root directory of my project then hit the command bower install jquery. It created a bower_components folder in my project and added the jquery folder perfectly.

Here is the structure created:

I then created a new index.html file and tried to reference that jquery file installed with Bower [I didn't modify any build path or anything, I actually am new to Eclipse]. The reference code is:

<head>
    <script src="bower_components/jquery/src/jquery.js" type="text/javascript"></script>
</head>

When I ran that page; looking through the developer tools I kept getting the error:

GET http://localhost:8080/PolymerTrials/bower_components/jquery/src/jquery.js 404 (Not Found) 

When I copy the URL in the browesr and hit enter I get:

I tried to manually add a new file named jquery.js in my directory and copy-pasted the jquery code inside and it managed to load it correctly. But any file I add with Bower and even though I make sure the referenced path is correct is never loaded. Again, I'm actually new to Eclipse and Bower and all this stuff, so I hope you can help. I feel that it's somehow not being included in the build. Any help is appreciated. Thanks!

解决方案

Looks like your files are not deployed by eclipse.

To fix this go to the "deployment assembly" page in project properties dialog. There you can see list of local resources which will be deployed by eclipse and their destinations. If you add your "bower_components" folder there and set its deploy path to "/bower" then you will be able to reference your jQuery by path "bower/jquery/src/jquery.js"

这篇关于无法使用Bower安装的文件在Eclipse中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆