Vaadin 10 和 springboot - 如何打包 jar?
Vaadin 10 and springboot - How to package a jar?
问题很简单,但我花了最后 2 天时间尝试部署我的应用程序。到目前为止还没有。
我的样式只有一个 css 文件,当我执行 jar 时,找不到 css (404) 或 jar 无法打包。
如此处所述:Spring Boot Executable jar structure
"Do not use the src/main/webapp folder if your application will be packaged as a jar"
和
"You should place your static resources in src/main/resources instead."
所以把 css 放在这里:
src/main/resources/styles.css
在 Vaadin 文档中(非常注重如何打包...)我这样导入 css:
@StyleSheet("styles.css")
来源:https://vaadin.com/docs/v11/flow/importing-dependencies/tutorial-include-css.html
然后我打包我的项目:
mvn clean package -Pproduction
我收到此错误:
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:11.0.0:package-for-production (default) on project importparcoursup: Execution default of goal com.vaadin:vaadin-maven-plugin:11.0.0:package-for-production failed: An import that ends with 'styles.css' cannot be resolved: the corresponding file 'C:\Workspace\lasteclipeandjava10\parcoursup\target\frontend\styles.css' was not found.
[ERROR] Double check the corresponding import and verify the following:
[ERROR] * the import string is correct
[ERROR] * the file imported is either present in 'frontend://' directory of the project or in one of the project WebJar dependencies or in one of the regular jar dependencies
[ERROR] * if the file is present in one of the regular jar dependencies, it should be located in `META-INF/resources/frontend` directory in the jar
有人可以提供一个简单的 'springboot + Vaadin10' 应用程序示例,该应用程序被打包为内部有静态资源的 jar 吗?
我尝试了很多配置(将 css 放在 META-INF 中,在 maven 构建过程中包含 webapp 资源...)但是 2 天后,我仍然无法将我的应用程序部署到服务器!
终于解决了
css 必须在这里:
src/main/resources/META-INF/resources/frontend/styles.css
然后声明为:
@StyleSheet("frontend://styles.css")
即使我仍然错过了一个示例,这也可能会有所帮助:
Vaadin 10 makes some changes to the way it loads static resources,
such as application templates, custom styles and any additional
JavaScript files. The gist of it is that such files should be put in
src/main/webapp/frontend/ when building a .war file and
src/main/resources/META-INF/resources/frontend/ when building a .jar
file.
Link 到 Vaadin 文档:Vaadin 10 and static resources
问题很简单,但我花了最后 2 天时间尝试部署我的应用程序。到目前为止还没有。
我的样式只有一个 css 文件,当我执行 jar 时,找不到 css (404) 或 jar 无法打包。
如此处所述:Spring Boot Executable jar structure "Do not use the src/main/webapp folder if your application will be packaged as a jar" 和 "You should place your static resources in src/main/resources instead."
所以把 css 放在这里: src/main/resources/styles.css
在 Vaadin 文档中(非常注重如何打包...)我这样导入 css:
@StyleSheet("styles.css")
来源:https://vaadin.com/docs/v11/flow/importing-dependencies/tutorial-include-css.html
然后我打包我的项目:
mvn clean package -Pproduction
我收到此错误:
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:11.0.0:package-for-production (default) on project importparcoursup: Execution default of goal com.vaadin:vaadin-maven-plugin:11.0.0:package-for-production failed: An import that ends with 'styles.css' cannot be resolved: the corresponding file 'C:\Workspace\lasteclipeandjava10\parcoursup\target\frontend\styles.css' was not found.
[ERROR] Double check the corresponding import and verify the following:
[ERROR] * the import string is correct
[ERROR] * the file imported is either present in 'frontend://' directory of the project or in one of the project WebJar dependencies or in one of the regular jar dependencies
[ERROR] * if the file is present in one of the regular jar dependencies, it should be located in `META-INF/resources/frontend` directory in the jar
有人可以提供一个简单的 'springboot + Vaadin10' 应用程序示例,该应用程序被打包为内部有静态资源的 jar 吗?
我尝试了很多配置(将 css 放在 META-INF 中,在 maven 构建过程中包含 webapp 资源...)但是 2 天后,我仍然无法将我的应用程序部署到服务器!
终于解决了
css 必须在这里:
src/main/resources/META-INF/resources/frontend/styles.css
然后声明为:
@StyleSheet("frontend://styles.css")
即使我仍然错过了一个示例,这也可能会有所帮助:
Vaadin 10 makes some changes to the way it loads static resources, such as application templates, custom styles and any additional JavaScript files. The gist of it is that such files should be put in src/main/webapp/frontend/ when building a .war file and src/main/resources/META-INF/resources/frontend/ when building a .jar file.
Link 到 Vaadin 文档:Vaadin 10 and static resources