2016-11-29 7 views
1

私はspring boot vaadinプロジェクトをセットアップし、springs tutorialに従ってこのクラスを実装しましたが、localhost:8080/uiでuiにアクセスすることはできません。私は間違って何をしていますか?Spring BootとVaadin UIにアクセスできませんか?

私のUIクラス:ここ

package net.lawyd.server.ui; 

import com.vaadin.annotations.Theme; 
import com.vaadin.server.VaadinRequest; 
import com.vaadin.spring.annotation.SpringUI; 
import com.vaadin.ui.Button; 
import com.vaadin.ui.Notification; 
import com.vaadin.ui.UI; 

@SpringUI(path = "/ui") 
@Theme("valo") 
public class VaadinUI extends UI { 

    @Override 
    protected void init(VaadinRequest request) { 
     setContent(new Button("Click me", e -> Notification.show("Hello Spring+Vaadin user!"))); 
    } 
} 

は私のSpring構成クラスである:ここで

package net.lawyd.server.config; 

import org.springframework.context.annotation.ComponentScan; 
import org.springframework.context.annotation.Configuration; 
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 
import org.springframework.transaction.annotation.EnableTransactionManagement; 

@Configuration 
@ComponentScan("net.lawyd.server") 
@EnableJpaRepositories("net.lawyd.server") 
@EnableTransactionManagement 
public class SpringConfig { 

    // Nothing to do here 

} 

は私のpom.xmlです:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>net.lawyd</groupId> 
    <artifactId>lawyd-server</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.4.2.RELEASE</version> 
    </parent> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
     <java.version>1.8</java.version> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-data-jpa</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-jersey</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>com.vaadin</groupId> 
      <artifactId>vaadin-spring-boot-starter</artifactId> 
      <version>1.1.1</version> 
     </dependency> 

     <dependency> 
      <groupId>com.h2database</groupId> 
      <artifactId>h2</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>com.google.guava</groupId> 
      <artifactId>guava</artifactId> 
      <version>20.0</version> 
     </dependency> 
     <dependency> 
      <groupId>com.google.code.gson</groupId> 
      <artifactId>gson</artifactId> 
      <version>2.8.0</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>io.rest-assured</groupId> 
      <artifactId>rest-assured</artifactId> 
      <version>3.0.1</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

[UPDATE 1]私はこれに気づきましたログメッセージ:

シングルトンインスタンス がcom.vaadin.spring.VaadinConfiguration 'を拡張できません が早すぎて作成されています。典型的な原因は、BeanDefinitionRegistryPostProcessorの戻り値の型を持つ非static @Bean メソッドです。 このようなメソッドを 'static'として宣言することを検討してください。

[更新2] start.spring.ioを使用して空のスプリングブートアプリケーションを作成し、チュートリアルのデモを挿入しました。それはそこで働くので、私の設定で何かでなければなりません。

[UPDATE 3]私は、私はそれが動作Vaadinそれを取り出す際には、JerseyConfigとは何かを持っていますが、ジャージはもうない考え出し:

ここ
@SpringBootConfiguration 
public class JerseyConfig extends ResourceConfig { 

    public JerseyConfig() { 
     register(TodoResource.class); 
     register(HealthResource.class); 
    } 
} 

code on githubです。

+0

私も何の違いを行っていないSpringConfigでEnableVaadin' @ 'てみました。また、localhost:8080ではrootにアクセスしようとしましたが、何もしませんでした。 –

+0

"mvn spring-boot:run"を使ってプロジェクトを開始しましたか? – kometen

+0

違いはありません。 –

答えて

0

根本問題が見つかりました.Jerseyがルートにマップされていたため、ルート上のすべての呼び出しが傍受されました。 root以外の何かに@ApplicationPath("/api")を変更すると、問題を解決:

@SpringBootConfiguration 
@ApplicationPath("/api") 
public class JerseyConfig extends ResourceConfig { 
関連する問題