无法在 Eclipse 中的 Maven 项目中加载 Widgetsets
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18799890/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to load Widgetsets in maven project in eclipse
提问by arjacsoh
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:
我在eclipse
. 特别是我使用了vaadin (20.3.4) 书中vaadin-archetype-touchkit
描述的原型。在没有对默认生成的代码做任何更改的情况下,我使用带有目标的 maven 运行它。然后我编译了. 当我尝试在 Tomcat 7 上运行它时,我收到来自网页的奇怪消息:clean package
Widgetset
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 questionwhere 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?
它让我吃惊的Maven并没有创造一个web.xml
文件,虽然我在本教程已阅读,它不再需要的vaadin 7
。我已经阅读了类似的问题,建议在web.xml
文件中进行调整。我应该推断我还必须web.xml
手动创建一个文件吗?
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.
我也觉得很奇怪,当我对典型的 vaadin 7 应用程序的原型尝试相同的过程时,它运行正常。由于我必须开发一个 touchkit 应用程序,我将不胜感激任何关于我最初尝试中可能遗漏的建议。
回答by Yngwie89
The web.xml is no longer needed onlyif you use servlet 3.0 configuration (annotating your servlet as described 4.8.3. WEB Servlet Class)
仅当您使用 servlet 3.0 配置时才不再需要 web.xml (如4.8.3. WEB Servlet Class所述注释您的 servlet )
Usually you'd configure your Vaadin 3.0 Servlet Config in this way:
通常你会以这种方式配置你的 Vaadin 3.0 Servlet 配置:
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 @VaadinServletConfigurationas shortcut for setting vaadin-related params.
使用@VaadinServletConfiguration作为设置 vaadin 相关参数的快捷方式。
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.
现在,如果您的项目中没有 vaadin 插件(所以您使用的是默认小部件集),就是这样,不需要更多工作。
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
相反,如果您使用自定义插件,则必须@VaadinServletConfiguration
通过以这种方式添加 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 extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
//your init stuff here
}
}
Otherwise you must create the web.xml manually as usual...
否则你必须像往常一样手动创建 web.xml ......
When it comes to maven, I think you've just to run mvn clean packageand on the package phase the maven-vaadin-plugin will compile you're widgetset automatically.
当谈到 maven 时,我认为您只需运行mvn clean package并且在包阶段 maven-vaadin-plugin 将自动编译您是小部件集。
回答by geert3
For me, adding the following to pom.xml
helped:
对我来说,添加以下内容有pom.xml
帮助:
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
<version>${vaadin.version}</version>
</dependency>
回答by fulvaz zhang
here is the readme in the root of the project
这是项目根目录中的自述文件
To compile the entire project, run "mvn install". To run the application, run "mvn jetty:run" and open http://localhost:8080/.
要编译整个项目,请运行“mvn install”。要运行该应用程序,请运行“mvn jetty:run”并打开http://localhost:8080/。
To develop the theme, simply update the relevant theme files and reload the application. Pre-compiling a theme eliminates automatic theme updates at runtime - see below for more information.
要开发主题,只需更新相关主题文件并重新加载应用程序。预编译主题可消除运行时的自动主题更新 - 有关更多信息,请参见下文。
Debugging client side code - run "mvn vaadin:run-codeserver" on a separate console while the application is running - activate Super Dev Mode in the debug window of the application
调试客户端代码 - 在应用程序运行时在单独的控制台上运行“mvn vaadin:run-codeserver” - 在应用程序的调试窗口中激活超级开发模式
To produce a deployable production mode WAR: - change productionMode to true in the servlet class configuration (nested in the UI class) - run "mvn clean vaadin:compile-theme package" - See below for more information. Running "mvn clean" removes the pre-compiled theme. - test with "mvn jetty:run-war
要生成可部署的生产模式 WAR: - 在 servlet 类配置(嵌套在 UI 类中)中将 productionMode 更改为 true - 运行“mvn clean vaadin:compile-theme package” - 有关更多信息,请参见下文。运行“mvn clean”会删除预编译的主题。- 使用“mvn jetty:run-war”进行测试
follow the instruction and you will get the correct page : )
按照说明操作,您将获得正确的页面:)