Http://www.cnblogs.com/softidea/p/6064091.html
caused By:java.lang.noclassdeffounderror:org/springframework/context/event/genericapplicationlistener from the Above error, application is unable to find the class defined from the jar dependencies. Genericapplicationlistener is added from spring version 4.2.
Upgrade your spring version to 4.2 and recheck.
Http://stackoverflow.com/questions/31489947/noclassdeffounderror-genericapplicationlistener-when-switching-from-spring-bo
Spring Boot manages a bunch of dependencies for your and allows to add them without specifying the version. Spring Boot is obviously based on Spring Framework and uses the latest and greatest so you should avoid at all cost to fix The spring framework version to use yourself.
If you had upgraded to a newer version (to include a bug fix or something) make sure to remove the override Befo Re you upgrade Spring Boot as the new version it requires is incompatible with your override.
If you is using other projects this also provide a dependency management on spring Framework (such as Spring Clo UD) Make sure, the dependency management of Spring Boot takes precedence. With Maven, make sure to add the BOM as the first spring-boot-dependencies entry <dependenciesManagement> .
Http://stackoverflow.com/questions/31489947/noclassdeffounderror-genericapplicationlistener-when-switching-from-spring-bo
13.2 Maven
Maven users can inherit from the spring-boot-starter-parent project to obtain sensible defaults. The parent project provides the following features:
- java 1.6 as the default compiler level.
- utf-8 source encoding.
- a dependency Management sections, allowing you to Omit
< Version> tags for common dependencies, inherited from The Spring-boot-dependencies pom.
- sensible resource filtering.
- sensible plugin configuration (exec plugin, surefire, git commit id, shade).
- sensible resource filtering For
application.properties and application.yml including profile-specific files (e.g. < Code class= "literal" >application-foo.properties andapplication-foo.yml )
The last point:since the default Config files accept Spring style placeholders ( ${…?} ) The Maven filtering is changed To use @[email protected] placeholders (you can override this with a Maven property resource.delimiter ).
13.2.1 inheriting the starter parent
To configure your project to inherit from the spring-boot-starter-parent simply set the parent :
<!--Inherit defaults from Spring Boot--<parent> <groupid>org.springframework.boot </groupId> <artifactid>spring-boot-starter-parent<version>1.4.2.release</version></ parent>
|
You should only need to specify the Spring Boot version number on this dependency. If You import additional starters, you can safely omit the version number. |
With the setup, you can also override individual dependencies by overriding a property in your own project. For instance, to upgrade to another Spring Data release train you ' d add the following to your pom.xml .
<properties> <SPRING-DATA-RELEASETRAIN.VERSION>FOWLER-SR2</ spring-data-releasetrain.version></properties>
|
Check the spring-boot-dependencies Pom for a list of supported properties. |
13.2.2 Using Spring Boot without the parent POM
Not everyone likes inheriting from the spring-boot-starter-parent POM. Your own corporate standard parent if you are need to use, or if you are just prefer to explicitly declare all R Maven Configuration.
If you don't want spring-boot-starter-parent to use the and you can still keep the benefit of the dependency management (and not the plugin manage ment) by using a scope=import dependency:
<dependencymanagement> < dependencies> <dependency> <!--Import Depende ncy Management from Spring Boot-to <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-dependencies </artifactId> <version>1.4.2.release</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies ></DEPENDENCYMANAGEMENT>
That Setup does does allow you to override the individual dependencies using a property as explained above. To achieve the same result, you ' d need to add a entry in the Your dependencyManagement project before spring-boot-dependencies . For instance, to upgrade to another Spring Data release train you ' d add the following to your pom.xml .
<dependencyManagement><dependencies><!--Override Spring Data release train provided by Spring Boot--<dependency><groupid>org.springframework.data</groupId><artifactid>spring-data-releasetrain</artifactId><version>fowler-sr2</version> <scope>import</scope > <type>pom</type> </dependency > <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-dependencies </artifactid> <version>1.4.2.release </version> <type>pom</type> <scope>import</scope> </dependency> </dependencies></DEPENDENCYMANAGEMENT>
|
In the example above, we specify a BOM But an any dependency type can is overridden that is. |
13.2.3 Changing the Java version
The spring-boot-starter-parent chooses fairly conservative Java compatibility. If you want to follow we recommendation and use a later Java version of can add a property java.version :
<properties> <java.version>1.8</java.version></properties>
13.2.4 Using the Spring Boot Maven plugin
Spring Boot includes a Maven plugin that can package the project as an executable jar. Add the plugin to your sections if you want to use <plugins> it:
<build> <plugins> <plugin> <groupid>org.springframework.boot </groupId> <artifactid>spring-boot-maven-plugin</plugins></build>
|
If you use the Spring Boot Starter parent Pom, you have need to add the plugin, there is no need for to configure it unles s you want to the settings defined in the parent. |
"Turn" Java.lang.ClassNotFoundException:org.springframework.context.event.GenericApplicationListener