- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的目标是建立一个简单的多模块项目,它使用 Spring Boot 2、Gradle 4.x 和 Vaadin 8.x 作为 UI。 Vaadin 目前仅在其中一个子项目中使用,其他子项目提供服务或只是库。
我从 this really nice Spring tutorial 开始,它(尽管使用旧的 Gradle 语法)生成了一个工作测试项目作为开始。它包含一个“libaray”子项目和一个依赖于前者的“application”子项目。 “bootRun”和“bootJar”Gradle 任务都非常有效,并且在我将一些配置集中在父 build.grade 中后仍然有效。
然后我添加了 Vaadin Gradle Plugin到“应用程序”项目并更改端点以显示简单的 vaadin 标签。
问题是,现在当使用“bootRun”时,启动的应用程序不再能够访问它所依赖的“库”中的类。如果我删除代码中的任何依赖项,该应用程序可以工作,但一旦我引用“库”中的类(例如“MyService”),它就会崩溃并显示“java.lang.ClassNotFoundException”。
但是,当使用“bootJar”部署相同的应用程序并运行 jar 时,一切正常,因此可以解决模块间依赖关系。
现在我想知道我是否缺乏理解,Vaadin Gradle 插件需要额外/不同的模块依赖项配置?或者这可能是 Vaadin Gradle 插件中的错误或我的配置中的问题?
我已经阅读了这个插件的完整文档,但没有得到任何线索,已经搜索过网络,但我没有在这个特定的上下文中找到“NoClassDefFoundError”,也没有找到一个使用 Spring 的工作多模块项目示例启动和 Vaadin 8。
以下是相关示例代码(不包括导入):
hello.app.DemoApplication
@SpringBootApplication(scanBasePackages = "hello")
@RestController
public class DemoApplication {
//Service defined in dependent sub-project
private final MyService myService;
public DemoApplication(MyService myService) {
this.myService = myService;
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
hello.app.StartUI
/** Entry point for the Vaadin 8 UI */
@SpringUI
@SpringView
public class StartUI extends UI implements View {
@Override
protected void init(final VaadinRequest request) {
setContent(new Label("Hello vaadin"));
}
}
库gradle.properties
plugins { id "io.spring.dependency-management" version "1.0.5.RELEASE" }
ext { springBootVersion = '2.0.3.RELEASE' }
jar {
baseName = 'library'
version = '0.0.1-SNAPSHOT'
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports { mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") }
}
应用程序gradle.properties
plugins {
id "io.spring.dependency-management" version "1.0.5.RELEASE"
id "org.springframework.boot" version "2.0.3.RELEASE"
id 'com.devsoap.plugin.vaadin'version '1.3.1' //Add vaadin support
}
bootJar {
baseName = 'application'
version = '0.0.1-SNAPSHOT'
}
dependencies {
implementation project(':library') // Contains "MyService"
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.boot:spring-boot-starter-web')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
父(根)项目build.gradle
subprojects {
//Only plugins configured here applied to sub-projects.
apply plugin: "java-library"
apply plugin: "eclipse"
repositories { mavenCentral() }
sourceCompatibility = 1.8
}
当然,父项目的settings.gradle引用了子项目。
堆栈跟踪(稍微缩短)
java.lang.IllegalStateException: Cannot load configuration class: hello.app.DemoApplication
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:414) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:254) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:128) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
...
Caused by: java.lang.IllegalStateException: Unable to load cache item
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:79) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:480) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:337) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:138) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:110) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:403) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 12 common frames omitted
Caused by: java.lang.NoClassDefFoundError: hello/service/MyService
at java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:1.8.0_151]
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[na:1.8.0_151]
at java.lang.Class.getDeclaredConstructors(Class.java:2020) ~[na:1.8.0_151]
at org.springframework.cglib.proxy.Enhancer.generateClass(Enhancer.java:566) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
...
Caused by: java.lang.ClassNotFoundException: hello.service.MyService
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_151]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_151]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_151]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_151]
... 34 common frames omitted
更多信息:我在 Eclipse Photon 中使用 Buildship 2.2 插件和 Gradle 4.3。
最佳答案
我看到的一些事情:
您构建的不是 Java 库,而是 Java Web 应用程序,因此请忽略“java-library”插件。
管理插件的更好策略是使用 apply false 参数将它们全部注册到父项目中。然后在子项目中正常应用插件。这样您就可以将所有插件依赖项版本管理在一个地方
实现配置相当新,许多插件不支持它(例如gretty)。我会将它们切换为使用 compile 和 testCompile 来代替。
Spring 依赖管理插件确实具有侵入性,并非所有插件都支持它(Gradle Vaadin 插件就是其中之一)。我会跳过它并使用 Gradle 的 BOM 支持。 https://docs.gradle.org/4.6/userguide/managing_transitive_dependencies.html#sec:bom_import
关于java - 使用 Spring Boot "bootRun"启动的应用程序在包含 Gradle Vaadin 插件时导致 NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51858043/
我在互联网上搜索了很多小时,但没有找到满意的结果,所以 -VSTO Addin 和 COM Addin(我们作为类库项目制作并使用 Excel 对象)之间有什么区别?VSTO 项目是否有任何限制,例如
我在互联网上搜索了很多小时,但没有找到满意的结果,所以 -VSTO Addin 和 COM Addin(我们作为类库项目制作并使用 Excel 对象)之间有什么区别?VSTO 项目是否有任何限制,例如
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
我正在寻找有关如何构建可扩展 WCF 服务器(具有动态加载的服务)的建议,最好使用 System.Addins 或 MEF。 服务器应托管实现最小“插件”API(StartService/StopSe
有没有一种方法可以使用加载浏览器扩展/插件/插件的 headless 浏览器(即 PhantomJS、Selenium)来运行自动测试? 更具体地说,我想模拟广告拦截器(如 Ghostery、ad-b
我是 gradle 的新手,我使用 artifactory 作为我的 repo 服务器。我在网上查看了如何将我的项目发布到我的 repo 服务器,发现我可以使用 maven-publish 或使用 a
我想禁用某些状态的点击/事件,并仅使少数状态可点击。我通读了http://newsignature.github.io/us-map/处的文档,并且找不到与此问题相关的任何内容。 最佳答案 http:
据我了解,在Intellij中使用idea插件打开Maven构建的项目并不是最好的方法,即调用: mvn idea:idea 但是直接打开pom文件(Intellij有默认的Maven插件);同样的事
使用Artifactory plugin对于 Jenkins pipeline 来说是一种幸福,只要遵循文档就可以了。但后来我介绍了Maven Flatten plugin解析父模块和子模块 mvn
我已经安装了Elasticsearch版本1.7.1。一切正常。我也安装了 JDBC 驱动程序。检查下面我的插件文件夹 目录E:\Xampp\htdocs\my-elastic\elasticsear
在我使用 webpack common chunks 插件创建包含第三方库(如 angular、react、lodash 等)的 vendor 包之前,但后来我知道了 webpack dll
我们正在尝试使用(Jenkins、sonar、eclipse ...)安装 CI 平台。 为了让每个开发人员都可以在提交之前对他的代码进行分析,我想知道两种选择: 使用 Sonar 插件运行本地分析。
我知道这是一个比较特殊的问题。尽管如此,也许有些人知道这一点: 我想在 Eclipse 中使用 Maven 编译 Hector=> 分支:0.7.0 和标签:hector-0.7.0-29(https
我卡住了。我一直在尝试寻找或自己创建一个简单的准系统示例,说明如何为 VS 2010 Express 创建 Outlook 插件。我知道这在 VS 2010 Pro 中更简单,但是,在快速版本中真的不
我有以下排除过滤器来忽略所有 R 文件类: findbugs-exclude-filter.xml 当我将它用于 FindBugs-IDEA 插件时,它可以
我刚开始玩 CakePHP,我发现了 Wildflower CMS .我喜欢这个想法,并打算开始修补它。不过,我有一个问题。 在自述文件中,我发现了以下内容:“Wildflower 不是也不会是 Ca
虽然现在大部分情况都是使用n-api来编写插件,但是底层毕竟是v8(和libuv),使用v8编写简单的插件,同时熟悉v8的使用。 本文介绍在写c++插件时,简单又常用的写法,其实本质上,写插件
本篇是 Python 系列教程第 3 篇,更多内容敬请访问我的 Python 合集 Visual Studio Code的安装非常简单,就不放这里增加文章篇幅了。 相比PyCharm,V
Maven – 插件 什么是 Maven 插件? Maven 实际上是一个依赖插件执行的框架,每个任务实际上是由插件完成。Maven 插件通常被用来: 创建 jar 文件 创建 war
我正在编写一个插件来添加带有标签 [deposit_page] 的页面;该标记应替换为一些 PHP 代码。 这就是我所拥有的,但它不起作用。有什么我遗漏或做错了什么吗? function deposi
我是一名优秀的程序员,十分优秀!