0
votes

Spring Boot: SpringApplication.Run provoque Org.springFramework.Context.ApplicationContextException:

Je n'ai pas utilisé Java depuis de nombreuses années, mais maintenant j'aimerais utiliser Java / Groovy pour le développement Web. Les bottes de printemps semblent être l'option la plus recommandée à utiliser comme cadre de nos jours, alors j'essaie d'obtenir mon premier monde Hello à courir après le cours Création de votre première application de démarrage de printemps em> sur pluralsight.com .

J'ai utilisé Groovy pour les applications de console dans le passé. J'ai utilisé Eclipse, mais je n'ai aucune expérience avec Maven ou Gradle. Maintenant, j'ai installé Spring Tool Suite 3. P>

Je n'ai pas pu obtenir le premier exemple d'application à exécuter, le programme se termine par un message d'erreur (voir ci-dessous). Je suis censé ouvrir http: // localhost: 8080 code> dans le navigateur, mais aucun serveur n'est trouvé. Vous trouverez ci-dessous mes fichiers. P>

Pouvez-vous m'aider à repérer le problème? Je suis sur un Mac et le projet est mis en place en tant que projet Maven dans STS. P>

app.java strong> p>

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.1.RELEASE)

2019-01-03 22:32:08.034  INFO 77010 --- [           main] com.boot.App                             : Starting App on mb12.local with PID 77010 (/Users/pida/sts-workspace/das-boot/target/classes started by pida in /Users/pida/sts-workspace/das-boot)
2019-01-03 22:32:08.040  INFO 77010 --- [           main] com.boot.App                             : No active profile set, falling back to default profiles: default
2019-01-03 22:32:08.160  INFO 77010 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5032714f: startup date [Thu Jan 03 22:32:08 CET 2019]; root of context hierarchy
2019-01-03 22:32:09.263  INFO 77010 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/Users/pida/.m2/repository/org/springframework/spring-core/4.2.4.RELEASE/spring-core-4.2.4.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2019-01-03 22:32:09.799  WARN 77010 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.autoconfigure.web.ServerProperties org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration.properties; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is javax.validation.ValidationException: Unable to instantiate Configuration.
2019-01-03 22:32:09.818 ERROR 77010 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.autoconfigure.web.ServerProperties org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration.properties; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is javax.validation.ValidationException: Unable to instantiate Configuration.
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:764) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:357) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:305) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1124) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1113) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at com.boot.App.main(App.java:15) ~[classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.autoconfigure.web.ServerProperties org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration.properties; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is javax.validation.ValidationException: Unable to instantiate Configuration.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:195) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]

// Much output omitted

2019-01-03 22:32:09.823  INFO 77010 --- [           main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: unknown


4 commentaires

Pour démarrer, vous utilisez des versions de logiciels sérieusement obsolètes. STS est maintenant sur la version 4, et vous devez utiliser Boot 1.5.x ou 2.0.x. (Création d'un projet à partir de Start.Spring.IO ou de l'Assistant de démarrage Eclipse vous procurera les dernières versions.)


Votre référentiel Maven local peut avoir corrompu. Cela pourrait aider. Stackoverflow.com/ Questions / 41542986 / ...


Au lieu de cela, suivez ce cours pour apprendre le spring boot: youtube.com/watch?v=msxl2odexqw


Merci. J'ai choisi ces versions pour pouvoir suivre le cours. Je pourrais suivre le cours mentionné par Nikhil après avoir terminé le pluralsight, ce qui n'est pas le plus âgé (34 contre 25 mois).


3 Réponses :


0
votes

Depuis que vous utilisez le démarrage, il est apparu avec WebServer Inbuilt Tomcat. Essayez de changer le port NBER en ajoutant la propriété dans le fichier Application.Properties.

serveur.port = 8090


0 commentaires

0
votes

0 commentaires

1
votes

1.3 ne prend pas en charge Java 11 qui examinant cet avertissement d'accès réfléchissant semble probable. Java 11 n'est pris en charge que dans la chaussure de printemps 2.1.

Utilisez JDK8 ou mettez à niveau cette application pour utiliser le démarrage de ressort 2.1.

https://docs.spring.io/spring-boot/docs/1.3.0.Release/reference/html/geting-Started-system-requirs.html

Par défaut, Spring Boot 1.3.0.Release nécessite Java 7 et la structure de printemps 4.1.5 ou plus. Vous pouvez utiliser un démarrage à ressort avec Java 6 avec une configuration supplémentaire. Voir la section 79.9, «Comment utiliser Java 6» pour plus de détails. La prise en charge explicite de la construction est fournie pour Maven (3.2+) et les grades (1.12+). [Astuce]

Bien que vous puissiez utiliser des bottes à ressort avec Java 6 ou 7, nous recommandons généralement Java 8 si possible.

Comme mentionné, je vous recommande de ne pas utiliser de version 1.x pour la démarrage à ressort. C'est la fin de la vie en août de cette année.


1 commentaires

Merci, tout fonctionnant à l'aide de JDK 8. J'essaie de coller avec les outils recommandés pour le cours court que je suis suivant, mais je garderai à l'esprit de changer de démarrage de printemps 2 bientôt.