无法在eclipse中的maven项目中加载Widgetets [英] Failed to load Widgetsets in maven project in eclipse
问题描述
我已经在 eclipse
中使用maven创建了一个vaadin Web应用程序。特别是我使用了 vaadin-archetype-touchkit mobile.installation.htmlrel =nofollow noreferrer> vaadin(20.3.4)的书。没有对默认生成的代码进行任何更改,我已经用maven运行目标 clean package
。然后我编译了 Widgetset
。当我尝试在Tomcat 7上运行它时,我收到网页上的奇怪消息:
无法加载WidgetSet:
< WidgetSet Path> .DefaultWidgetSet.nocache.js
在控制台上我也看到错误消息:
INFO:请求的资源[/VAADIN/themes/reindeer/styles.css]没有从文件系统或类中找到装载机。将widgetset和/或主题JAR添加到您的类路径或将文件添加到WebContent / VAADIN文件夹。
INFO:请求的资源[/VAADIN/widgetsets/com.vaadin.DefaultWidgetSet/com.vaadin.DefaultWidgetSet.nocache.js]没有从文件系统或通过类加载器找到。将widgetset和/或主题JAR添加到您的类路径或将文件添加到WebContent / VAADIN文件夹。
INFO:请求的资源[/VAADIN/themes/reindeer/styles.css]没有从文件系统或通过类加载器找到。将widgetset和/或主题JAR添加到您的类路径或将文件添加到WebContent / VAADIN文件夹。
它已经触发我maven没有创建一个 web.xml
文件,虽然我已经在教程中阅读,在 vaadin 7
中不再需要。我已经阅读了类似问题,建议将应该在 web.xml
文件中进行调整。我应该推断我还要手动创建一个 web.xml
文件?
我也觉得奇怪,当我尝试与典型的vaadin 7应用程序的原型相同的过程时,它运行正常。由于我必须开发一个touchkit应用程序,我将不胜感激任何建议 - 想法跟踪我原来尝试可能丢失的内容。
如果您使用servlet 3.0配置,则不再需要web.xml servlet,如 4.8.3。WEB Servlet类)通常你可以这样配置你的Vaadin 3.0 Servlet配置:
public class MyUI extends UI {
@WebServlet(value =/ *,asyncSupported = true)
@VaadinServletConfiguration(productionMode = false,ui = MyUI.class)
public static class Servlet扩展VaadinServlet {
}
@Override
protected void init(VaadinRequest request){
//你的init东西这里
}
}
使用 @VaadinServletConfiguration 作为设置vaadin的快捷方式相关的参数。
现在,如果没有vaad在你的项目的插件(所以你使用默认的widgetset),就是这样,不需要更多的工作。
相反,如果您使用自定义插件,则必须在 @VaadinServletConfiguration
中指定要使用的widgetset通过以这种方式添加widgetset参数
public class MyUI extends UI {
@WebServlet(value =/ *,asyncSupported = true)
@VaadinServletConfiguration(widgetset =com.bla.bla.MyWidgetSet,productionMode = false,ui = MyUI.class)
public static class Servlet扩展VaadinServlet {
}
@Override
protected void init(VaadinRequest request){
//你的init东西在这里
}
}
否则,您必须按常规手动创建web.xml ...
当涉及到maven时,我想你只需要运行 mvn clean package ,并且在软件包阶段,maven-vaadin-plugin会自动编译你的widgetset。 p>
I have created a vaadin web application using maven in eclipse
. In particular I have used the archetype vaadin-archetype-touchkit
as described in the book of vaadin (20.3.4). Without making any change on the default generated code I have run it with maven with goals clean package
. Then I compiled the Widgetset
. When I try to run it on Tomcat 7, I receive the strange message from the webpage:
Failed to load the WidgetSet:
<WidgetSet Path>.DefaultWidgetSet.nocache.js
On the console I see also the error messages:
INFO: Requested resource [/VAADIN/themes/reindeer/styles.css] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
INFO: Requested resource [/VAADIN/widgetsets/com.vaadin.DefaultWidgetSet/com.vaadin.DefaultWidgetSet.nocache.js] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
INFO: Requested resource [/VAADIN/themes/reindeer/styles.css] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
It has struck me maven has not created a web.xml
file, although I have read in the tutorial that it is no more necessary in vaadin 7
. I have read the similar question where it is proposed that an adjustment in web.xml
file should be done. Should I infer that I have also to create a web.xml
file manually?
I find strange as well, that when I tried the same procedure with the archetype for a typical vaadin 7 application, it runs properly. Since I have to develop a touchkit-application I would appreciate any suggestion-idea abut what could be missing on my original attempt.
The web.xml is no longer needed only if you use servlet 3.0 configuration (annotating your servlet as described 4.8.3. WEB Servlet Class)
Usually you'd configure your Vaadin 3.0 Servlet Config in this way:
public class MyUI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MyUI.class)
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
//your init stuff here
}
}
Where using the @VaadinServletConfiguration as shortcut for setting vaadin-related params.
Now, if you have no vaadin addon in your project (so you're using the default widgetset), that's it, no more work is required.
Instead, if you're using custom addons, you must specify which widgetset to use in the @VaadinServletConfiguration
simply by adding the widgetset parameter in this way
public class MyUI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(widgetset="com.bla.bla.MyWidgetSet",productionMode = false, ui = MyUI.class)
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
//your init stuff here
}
}
Otherwise you must create the web.xml manually as usual...
When it comes to maven, I think you've just to run mvn clean package and on the package phase the maven-vaadin-plugin will compile you're widgetset automatically.
这篇关于无法在eclipse中的maven项目中加载Widgetets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!