亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

當包含 Gradle Vaadin 插件時,使用 Spring Boot“bootRun

當包含 Gradle Vaadin 插件時,使用 Spring Boot“bootRun

DIEA 2021-07-17 14:02:57
我的目標是建立一個簡單的多模塊項目,它使用 Spring Boot 2、Gradle 4.x 和 Vaadin 8.x 作為 UI。Vaadin 目前僅用于其中一個子項目,其他子項目提供服務或只是庫。我從這個非常好的 Spring 教程開始,它(盡管使用了較舊的 Gradle 語法)生成了一個工作測試項目。它包含一個“libaray”子項目和一個“應用程序”子項目,具體取決于前者?!癰ootRun”和“bootJar”Gradle 任務都像魅力一樣工作,并且在我將一些配置集中在父 build.grade 中后仍然有效。然后我將Vaadin Gradle Plugin添加到“應用程序”項目并更改端點以顯示一個簡單的 vaadin 標簽。問題是,現在使用“bootRun”時,啟動的應用程序不再能夠訪問它所依賴的“庫”中的類。如果我刪除代碼中的任何依賴項,應用程序就可以工作,但是一旦我從“庫”(例如“MyService”)中引用了一個類,它就會因“java.lang.ClassNotFoundException”而崩潰。但是,當使用“bootJar”部署相同的應用程序并運行 jar 時,一切正常,因此可以解決模塊間依賴關系。現在我想知道我是否缺乏理解并且 Vaadin Gradle 插件需要額外/不同的模塊依賴配置?或者這可能是 Vaadin Gradle 插件中的錯誤還是我的配置中的問題?我在沒有得到任何線索的情況下閱讀了這個插件的完整文檔,已經在網上搜索過,但我既沒有在這個特定的上下文中找到“NoClassDefFoundError”,也沒有找到一個同時包含 Spring Boot 和 Vaadin 的工作多模塊項目示例8.這是相關的示例代碼(不包括導入):hello.app.DemoApplication@SpringBootApplication(scanBasePackages = "hello")@RestControllerpublic 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@SpringViewpublic class StartUI extends UI implements View {    @Override    protected void init(final VaadinRequest request) {        setContent(new Label("Hello vaadin"));    }}庫gradle.propertiesplugins { 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}") }}
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 178 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號