我在Java Project中收到此错误消息。怎么解决?我只是构建了Vaadin的标准archtype应用程序示例。我想尝试将JavaScript包含到我的项目中。但是,简单的注释已经给出了错误消息:@JavaScript没有注释类型
我试过这个:Project-> Properties-> JavaCompiler-> AnnotationProcessing-> Enable仍然是一个错误。也许我必须包括某些.jars?
这是代码:
package my.vaadin.app;
import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.annotations.*;
/**
* This UI is the application entry point. A UI may either represent
* a browser window
* (or tab) or some part of an HTML page where a Vaadin application
* is embedded.
* <p>
* The UI is initialized using {@link #init(VaadinRequest)}. This
* method is intended to be
* overridden to add component to the user interface and initialize
* non-component functionality.
*/
@Theme("mytheme")
@JavaScript("javascript-test.js")
public class MyUI extends UI {
@Override
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout layout = new VerticalLayout();
final TextField name = new TextField();
name.setCaption("Type your name here:");
Button button = new Button("Click Me");
button.addClickListener(e -> {
layout.addComponent(new Label("Thanks " + name.getValue()
+ ", it works!"));
});
layout.addComponents(name, button);
setContent(layout);
}
@WebServlet(urlPatterns = "/*", name = "MyUIServlet",
asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class, productionMode =
false)
public static class MyUIServlet extends VaadinServlet {
}
}
尝试导入它:
import com.vaadin.ui.JavaScript;
奇怪的是,这确实是一个缺失的导入。我变了
import com.vaadin.annotations.*;
至
import com.vaadin.annotations.JavaScript;
它的工作原理。我也包括在内
<swagger-core-version>1.5.15</swagger-core-version>
属性和
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-core-version}</version>
</dependency>
进入pom.xml