Spring Boot - java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextInitializer

匿名 (未验证) 提交于 2019-12-03 07:36:14

问题:

I am trying to deploy a simple Spring Boot web app to Pivotal Cloud foundry, but I get the below error in my logs when i perform a cf push

java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextInitializer 

Here is my pom.xml

    <parent>     <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-starter-parent</artifactId>     <version>1.4.0.BUILD-SNAPSHOT</version>     <relativePath /> <!-- lookup parent from repository --> </parent>  <properties>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>     <java.version>1.7</java.version> </properties>  <dependencies>     <dependency>         <groupId>org.springframework.boot</groupId>         <artifactId>spring-boot-starter-web</artifactId>     </dependency>      <dependency>         <groupId>org.springframework.boot</groupId>         <artifactId>spring-boot-starter-tomcat</artifactId>         <scope>provided</scope>     </dependency>     <dependency>         <groupId>org.springframework.boot</groupId>         <artifactId>spring-boot-starter-test</artifactId>         <scope>test</scope>     </dependency>     <dependency>         <groupId>org.springframework</groupId>         <artifactId>spring-webmvc-portlet</artifactId>     </dependency> </dependencies>  <build>     <plugins>         <plugin>             <groupId>org.springframework.boot</groupId>             <artifactId>spring-boot-maven-plugin</artifactId>         </plugin>     </plugins> </build>  <repositories>     <repository>         <id>spring-snapshots</id>         <name>Spring Snapshots</name>         <url>https://repo.spring.io/snapshot</url>         <snapshots>             <enabled>true</enabled>         </snapshots>     </repository>     <repository>         <id>spring-milestones</id>         <name>Spring Milestones</name>         <url>https://repo.spring.io/milestone</url>         <snapshots>             <enabled>false</enabled>         </snapshots>     </repository> </repositories> <pluginRepositories>     <pluginRepository>         <id>spring-snapshots</id>         <name>Spring Snapshots</name>         <url>https://repo.spring.io/snapshot</url>         <snapshots>             <enabled>true</enabled>         </snapshots>     </pluginRepository>     <pluginRepository>         <id>spring-milestones</id>         <name>Spring Milestones</name>         <url>https://repo.spring.io/milestone</url>         <snapshots>             <enabled>false</enabled>         </snapshots>     </pluginRepository> </pluginRepositories> 

The same app gets deployed in my local host and I have no issues building the war. Any thoughts on this ?

回答1:

As Andy Wilkinson pointed out, this is an issue in a mismatch between Spring Boot 1.4 and the java_buildpack. It can be solved by explicitly mentioning the URL to the java_buildpack:

$ cf push -b https://github.com/cloudfoundry/java-buildpack.git … 


回答2:

Seems like a jar did not download during the maven build due to an SSL handshake exception. For some reason my build did not fail in spite of the missing jar. Found this by enabling debug during the mvn clean install



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!