如何解决Vaadin无法导入CSS文件
因此,我对Vaadin以及所有这些东西都不熟悉,而我目前正在尝试将CSS文件集成到我的网站中。但是,当我尝试执行此操作时,尝试运行gradle-Project后出现错误:
java.lang.IllegalStateException:
Failed to find the following css files in the `node_modules` or `C:\Users\Sebastian Malburg\Documents\Schule_4\SYT\Wind-2\windpark_REST_JSON\.\frontend` directory tree:
- ./frontend/table_style.css
因此,很明显,CSS文件的路径是错误的,但是我不知道从哪里开始。我在互联网上的某个地方读到它从项目的根文件夹(我的build.gradle-File所在的文件夹)开始,但是似乎不起作用。
这是我的使用注释的课程:
package windpark.windengine;
import java.awt.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.dependency.StyleSheet;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.data.provider.ListDataProvider;
import com.vaadin.flow.data.renderer.ComponentRenderer;
import com.vaadin.flow.router.Route;
import windpark.model.WindengineData;
@CssImport("./frontend/table_style.css")
@Route("windengine/tables")
public class GridView extends VerticalLayout {
final Grid<WindengineData> grid;
private WindengineService service;
public GridView() {
...
}
}
编辑:
我已经尝试过./table_style
。我认为问题可能在于路径:C:\Users\Sebastian Malburg\Documents\Schule_4\SYT\Wind-2\windpark_REST_JSON\.\frontend
,这是Vaadin在思考中自动使用的。我猜\.\
无效?我将如何更改此路径?
解决方法
您的CSS文件放置在错误的目录中。您可以在target/frontend
下找到它。相反,应将其放在项目目录内的/frontend
下。
一旦放置在那儿,您应该使用@CssImport("./table_style.css")
,如Shubham所述。
Use only file name of css,since your css in frontend folder
@CssImport("./table_style.css")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。