由于网络上的其它博文,没能解决我的这个问题,然后就记录一下。或许还有很多其它原因导致这个问题的发生,这里就简述一下我遇到的。其它的遇到了再补充吧。
1. pom依赖中tomcat引入的问题:
SpringBoot项目启动后 迅速 执行结束,控制台打印: No active profile set, falling back to default profiles: default,并执行结束:Process finished with exit code 0.(如下图)
经验证,系 pom 文件配置的 tomcat 发生错误导致,原配置tomcat如下:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
修改后:(删去<scope>):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
对于scope标签的用法,我就不细述了,可以参考这个博文。
2. pom依赖中并没有引入tomcat依赖,但是报了这个如下代码块1中的错误。在引入web依赖后报错解决。原因暂时未知
2019-07-30 19:20:33.673 INFO 88540 --- [ main] com.sell.product.ProductApplication : No active profile set, falling back to default profiles: default
2019-07-30 19:20:33.689 INFO 88540 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@10f7f7de: startup date [Tue Jul 30 19:20:33 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@62150f9e
2019-07-30 19:20:34.184 INFO 88540 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'dataSource' with a different definition: replacing [Root bean: class [null]; scope=refresh; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=false; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]] with [Root bean: class [org.springframework.aop.scope.ScopedProxyFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]]
2019-07-30 19:20:34.298 INFO 88540 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=b6cb8ecd-e9ba-33f0-a93c-fc4c9e111ee9
2019-07-30 19:20:34.314 INFO 88540 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-07-30 19:20:34.383 INFO 88540 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$f7f824ad] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-07-30 19:20:34.424 INFO 88540 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$141227aa] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-07-30 19:20:34.656 INFO 88540 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-07-30 19:20:34.882 INFO 88540 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-07-30 19:20:34.936 INFO 88540 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2019-07-30 19:20:34.952 INFO 88540 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-07-30 19:20:35.042 INFO 88540 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2019-07-30 19:20:35.043 INFO 88540 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-07-30 19:20:35.088 INFO 88540 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2019-07-30 19:20:35.242 INFO 88540 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2019-07-30 19:20:35.467 INFO 88540 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-07-30 19:20:35.497 WARN 88540 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-07-30 19:20:35.498 INFO 88540 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-07-30 19:20:35.501 WARN 88540 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-07-30 19:20:35.501 INFO 88540 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-07-30 19:20:36.572 INFO 88540 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2019-07-30 19:20:36.573 INFO 88540 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2019-07-30 19:20:36.579 INFO 88540 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'refreshScope' has been autodetected for JMX exposure
2019-07-30 19:20:36.580 INFO 88540 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2019-07-30 19:20:36.581 INFO 88540 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'environmentManager' has been autodetected for JMX exposure
2019-07-30 19:20:36.584 INFO 88540 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2019-07-30 19:20:36.600 INFO 88540 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2019-07-30 19:20:36.609 INFO 88540 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=10f7f7de,type=ConfigurationPropertiesRebinder]
2019-07-30 19:20:36.615 INFO 88540 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2019-07-30 19:20:36.620 INFO 88540 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2019-07-30 19:20:36.633 INFO 88540 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2019-07-30 19:20:36.662 INFO 88540 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2019-07-30 19:20:37.195 INFO 88540 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2019-07-30 19:20:37.195 INFO 88540 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2019-07-30 19:20:37.304 INFO 88540 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2019-07-30 19:20:37.304 INFO 88540 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2019-07-30 19:20:37.505 INFO 88540 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2019-07-30 19:20:37.722 INFO 88540 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2019-07-30 19:20:37.723 INFO 88540 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2019-07-30 19:20:37.723 INFO 88540 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2019-07-30 19:20:37.723 INFO 88540 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2019-07-30 19:20:37.723 INFO 88540 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2019-07-30 19:20:37.723 INFO 88540 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2019-07-30 19:20:37.723 INFO 88540 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2019-07-30 19:20:37.824 INFO 88540 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2019-07-30 19:20:37.826 INFO 88540 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30
2019-07-30 19:20:37.827 INFO 88540 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2019-07-30 19:20:37.834 INFO 88540 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1564485637832 with initial instances count: 0
2019-07-30 19:20:37.839 INFO 88540 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application PRODUCT with eureka with status UP
2019-07-30 19:20:37.840 INFO 88540 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1564485637840, current=UP, previous=STARTING]
2019-07-30 19:20:37.841 INFO 88540 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_PRODUCT/DESKTOP-5D84UID:product: registering service...
2019-07-30 19:20:37.856 INFO 88540 --- [ main] com.sell.product.ProductApplication : Started ProductApplication in 6.33 seconds (JVM running for 7.69)
2019-07-30 19:20:37.858 INFO 88540 --- [ Thread-18] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@10f7f7de: startup date [Tue Jul 30 19:20:33 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@62150f9e
2019-07-30 19:20:37.859 INFO 88540 --- [ Thread-18] o.s.c.n.e.s.EurekaServiceRegistry : Unregistering application PRODUCT with eureka with status DOWN
2019-07-30 19:20:37.859 WARN 88540 --- [ Thread-18] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1564485637859, current=DOWN, previous=UP]
2019-07-30 19:20:37.860 INFO 88540 --- [ Thread-18] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
2019-07-30 19:20:37.863 INFO 88540 --- [ Thread-18] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2019-07-30 19:20:37.864 INFO 88540 --- [ Thread-18] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
2019-07-30 19:20:37.866 INFO 88540 --- [ Thread-18] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2019-07-30 19:20:37.867 INFO 88540 --- [ Thread-18] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2019-07-30 19:20:37.869 WARN 88540 --- [ Thread-18] .s.c.a.CommonAnnotationBeanPostProcessor : Invocation of destroy method failed on bean with name 'scopedTarget.eurekaClient': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaInstanceConfigBean': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
2019-07-30 19:20:37.869 INFO 88540 --- [ Thread-18] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2019-07-30 19:20:37.874 INFO 88540 --- [ Thread-18] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
Process finished with exit code 0
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>