2016-03-22 23 views
1

私は比較的新しいvaadinで、春の起動アプリケーションとvaadinの春のブートプラグインを使い始めました。私は自分のコンポーネント/ウィジェットを作成しようとするまで、すべてうまく動作しました。MavenとSpringブートを備えたVaadinカスタムコンポーネント/ウィジェット

残念ながら私は春の起動アプリケーションでカスタムコンポーネントを設定する方法についての公式のサンプル/ドキュメンテーションが見つかりませんでしたので、追加のプラグインをmavenに設定する方法を見つけるためにウェブを検索しなければなりませんでしたクライアント側のウィジェット用のコードをコンパイルします。私の知る限り、ログ出力から、これらのコンポーネントのコンパイルを伝えることができるように動作しますが、私は、ウェブページ上のこれらのコンポーネントにアクセスしようとするとエラーが表示されます。ここでは

Widgetset 'com.vaadin.DefaultWidgetSet' does not contain implementation for net.gtidev.test.components.MyComponent. Check its component connector's @Connect mapping, widgetsets GWT module description file and re-compile your widgetset. [...] 

は、ウィジェットコンパイラのログです:

[INFO] Using com.vaadin:vaadin-client-compiler version 7.6.4 
[ERROR] Mar 22, 2016 10:22:43 AM java.util.prefs.WindowsPreferences <init> 
[ERROR] WARNUNG: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5. 
[INFO] Compiling module net.gtidev.test.components.TestWidgetset 
[INFO] Computing all possible rebind results for 'com.vaadin.client.metadata.ConnectorBundleLoader' 
[INFO]  Rebinding com.vaadin.client.metadata.ConnectorBundleLoader 
[INFO]   Invoking generator com.vaadin.server.widgetsetutils.ConnectorBundleLoaderFactory 
[INFO]    Populating eager bundle 

. . . . . 250 more lines 

[INFO] Computing all possible rebind results for 'com.vaadin.client.ui.dd.VAcceptCriterionFactory' 
[INFO]  Rebinding com.vaadin.client.ui.dd.VAcceptCriterionFactory 
[INFO]   Invoking generator com.vaadin.server.widgetsetutils.AcceptCriteriaFactoryGenerator 
[INFO]    Detecting available criteria ... 
[INFO]    creating mapping for com.vaadin.event.dd.acceptcriteria.AcceptAll 
[INFO]    creating mapping for com.vaadin.event.dd.acceptcriteria.And 
[INFO]    creating mapping for com.vaadin.event.dd.acceptcriteria.ContainsDataFlavor 
[INFO]    creating mapping for com.vaadin.event.dd.acceptcriteria.SourceIs 
[INFO]    creating mapping for com.vaadin.ui.AbstractSelect.TargetItemIs 
[INFO]    creating mapping for com.vaadin.ui.AbstractSelect.AcceptItem 
[INFO]    creating mapping for com.vaadin.ui.Table.TableDropCriterion 
[INFO]    creating mapping for com.vaadin.ui.Tree.TreeDropCriterion 
[INFO]    creating mapping for com.vaadin.event.dd.acceptcriteria.Not 
[INFO]    creating mapping for com.vaadin.event.dd.acceptcriteria.Or 
[INFO]    creating mapping for com.vaadin.event.dd.acceptcriteria.ServerSideCriterion 
[INFO]    creating mapping for com.vaadin.event.dd.acceptcriteria.SourceIsTarget 
[INFO]    creating mapping for com.vaadin.event.dd.acceptcriteria.TargetDetailIs 
[INFO]    creating mapping for com.vaadin.ui.Tree.TargetInSubtree 
[INFO]    Done. (0seconds) 
[INFO] Compiling 1 permutation 
[INFO]  Compiling permutation 0... 
[INFO] Compile of permutations succeeded 
[INFO] Compilation succeeded -- 59,217s 
[INFO] Linking into C:\projects\misc\vaadin-boot\target\vaadin-boot-0.0.1-SNAPSHOT\net.gtidev.test.components.TestWidgetset 
[INFO] Link succeeded 
[INFO] Linking succeeded -- 0,492s 

カスタムコンポーネントに使用するファイルは、この目的でのみ作成したvaadin 7プロジェクト内のeclipse vaadinアドオンによって生成されました。私がこのvaadin 7プロジェクトをEclipseで起動したとき、コンポーネントは機能しました。私はこれらのファイルを私のspring boot mavenプロジェクトにコピーしました。ここでカスタムコンポーネントはそれ以上ロードされません。

私は春のブートアプリケーションは、 "古典的な" webappsとは若干異なるブートストラップメカニズムとレイアウトを持っていることを知っています。静的リソースはwebapp-folderではなくclasspath:/ staticフォルダから読み込まれます。問題の中核はこの事実と関係があると私は思うが、私はそれを修正するために何をすべきか分からない。

マイプラグイン構成(私はコメントオプションで及びなしで試み):

<plugin> 
    <groupId>com.vaadin</groupId> 
    <artifactId>vaadin-maven-plugin</artifactId> 
    <version>7.6.4</version> 
    <configuration> 
    <strict>true</strict> 
    <force>true</force> 
    <!-- Enable during development to speed compiling. --> 
    <!-- <draftCompile>true</draftCompile> 
    <style>DETAILED</style> --> 
    <!-- End development options --> 
    <!--<webappDirectory>src/main/webapp/VAADIN/widgetsets</webappDirectory>--> 
    <modules> 
     <module>net.gtidev.test.components.TestWidgetset</module> 
    </modules> 
    </configuration> 
    <executions> 
    <execution> 
     <goals> 
     <goal>resources</goal> 
     <goal>compile</goal> 
     </goals> 
    </execution> 
    </executions> 
</plugin> 

Iは組合せおよび構成をプラグイン異なるMavenを試みました。一例では、また、Google-GWTプラグインが言及されたが、コードの上にこのプラグインを実行するとvaadinプラグインとして同じログ出力を生成:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>gwt-maven-plugin</artifactId> 
    <version>2.5.1</version> 
    <!--<configuration>--> 
    <!--<webappDirectory>src/main/webapp/VAADIN/widgetsets</webappDirectory>--> 
    <!--<extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>--> 
    <!--<runTarget>clean</runTarget>--> 
    <!--<hostedWebapp>${project.build.directory}/${project.build.finalName}</hostedWebapp>--> 
    <!--<noServer>true</noServer>--> 
    <!--<port>8080</port>--> 
    <!--<soycDetailed>false</soycDetailed>--> 
    <!--</configuration>--> 
    <executions> 
    <execution> 
     <goals> 
     <goal>resources</goal> 
     <goal>compile</goal> 
     </goals> 
    </execution> 
    </executions> 
</plugin> 
+0

Vaadin 7でgwt-maven-pluginを使用しないでください。gwt-maven-pluginはVaadin 6シリーズで使用しています。私はあなたの元の試行がほぼ正しいと思う、ブートだけがsrc/main/webappを調べないので、設定が必要です。下の私の答えを見てください。 – mstahv

答えて

2

カスタムクライアント側拡張機能を使用するには、Vaadinは、アドオンプロジェクトにvaadin-maven-pluginを追加する必要があります。それはあなたが使用するアドオンをスキャンし、GWTはそれらの拡張を含むあなたのプロジェクト用の新しいウィジェットセットをコンパイルします。

start.spring.ioでプロジェクトを作成した場合、mavenプラグインはデフォルトでプロジェクトに含まれていません。たとえば、このVaadin+Spring archetypeまたは公式サーブレットベースarchetypeを使ってサンプルプロジェクトを作成し、vomin-maven-plugin関連の部分をpom.xmlからプロジェクトpom.xmlにコピーします。その後、完全なビルドを行い、すべてが期待どおりに動作するはずです。

+0

ありがとう! 「この変更」は私が問題を解決するのを助けました。私はまだいくつかのajdustmentsをしなければならなかったし、私は@Widgetset( "MyWidgetset")を私のメインUIに追加しなければならなかった。 – gofrm

+0

なぜ@Widgetsetアノテーション( "MyWidgetset") 'を使う必要があると書いていないのですか? – Alex78191

+0

答えはちょっと古く、ちょうど2018年に更新されました。 – mstahv

関連する問題