Spring启动错误:由于缺少EmbeddedServletContainerFactory bean,无法启动EmbeddedWebApplicationContext

Spring启动错误:由于缺少EmbeddedServletContainerFactory bean,无法启动EmbeddedWebApplicationContext,spring,spring-boot,spring-data-gemfire,Spring,Spring Boot,Spring Data Gemfire,我试图使用Spring数据GemFire将数据放入GemFire 我跟着这个 StockRepository类: public interface StockRepository extends CrudRepository<StockInfo, String> { StockInfo findByName(String symbol); } 您需要将@SpringBootApplication添加到主类中 @EnableGemfireRepositories @Spri

我试图使用Spring数据GemFire将数据放入GemFire

我跟着这个

StockRepository类:

public interface StockRepository extends CrudRepository<StockInfo, String> {
    StockInfo findByName(String symbol);

}

您需要将@SpringBootApplication添加到主类中

@EnableGemfireRepositories
@SpringBootApplication
public class Application implements CommandLineRunner {
在pom中添加SpringBootStarterWeb依赖项,而不是SpringWeb依赖项

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

org.springframework.boot
SpringBootStarterWeb

< /代码> < p>为了简化您的Spring启动应用程序中的Pivotal GemFire配置,您可以考虑使用(开始)<强> Spring Bug为Pivotal GemFire < /强>(SBDG)。

SBDG基于Pivotal GemFire(SDG)的Spring数据以及其他Spring项目,显然是Spring Boot,但也基于Pivotal GemFire(SSDG;)的Spring会话。在使用Spring(尤其是Spring Boot)开发关键GemFire应用程序时,它应用了Spring Boot的所有概念(例如,自以为是的、使用自动配置的“约定优先于配置”等)

例如,在您的应用程序中,SBDG将自动配置SD[G]存储库,从而不需要显式声明
@enablegmFireRepositories

使用SBDG还有许多其他好处


值得深思。

最有可能的重复项是您的系统中缺少的
spring boot maven插件
pom@jny.就在那儿。。org.springframework.boot spring boot maven plugin您如何构建和运行它?java-jar GeodeRest-0.0.1-SNAPSHOT.jar实际上,我注意到您使用的是spring boot 1.x,它当时有
spring boot starter数据gemfire
模块。自Spring Boot
2.0
起,该起动器模块不再存在,并由我在上述回答中提到的SBDG项目取代。
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.0.RELEASE</version>
    </parent>
    <properties>
        <java.version>1.7</java.version>
    </properties>
    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-gemfire</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency> 
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
    </dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </repository>
</repositories> 
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at com.emc.geode.entity.Application.main(Application.java:62) [classes/:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:183) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:156) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    ... 8 common frames omitted
@EnableGemfireRepositories
@SpringBootApplication
public class Application implements CommandLineRunner {
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>