简体   繁体   中英

Spring boot doesn't load application.yml

i have a application.yml to auto-creation some table:

## JDBC part
spring:
  config:
    activate:
      on-profile: local
  enabled: true
  datasource:
    url: jdbc:mysql://localhost:3306/kazi?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: emo
    password: 123qwe
  jpa:
    show-sql: true
    database-platform: org.hibernate.dialect.MySQL8Dialect
    hibernate:
      ddl-auto: update
  liquibase:
    change-log: classpath:liquibase/changelog.xml
#spring.jpa.properties.hibernate.hbm2ddl.import_files=import.sql

main class:

@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class)
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Log

/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=57211:/Applications/IntelliJ IDEA.app/Contents/bin -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath /Users/emoleumassi/Documents/Projects/me/kazi/kazi-core/target/classes:/Users/emoleumassi/.m2/repository/org/liquibase/liquibase-core/4.5.0/liquibase-core-4.5.0.jar:/Users/emoleumassi/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar:/Users/emoleumassi/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar:/Users/emoleumassi/.m2/repository/org/liquibase/liquibase-maven-plugin/3.8.2/liquibase-maven-plugin-3.8.2.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-plugin-api/2.0/maven-plugin-api-2.0.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-project/2.0/maven-project-2.0.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-profile/2.0/maven-profile-2.0.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-model/2.0/maven-model-2.0.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-artifact-manager/2.0/maven-artifact-manager-2.0.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-repository-metadata/2.0/maven-repository-metadata-2.0.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/wagon/wagon-provider-api/1.0-alpha-5/wagon-provider-api-1.0-alpha-5.jar:/Users/emoleumassi/.m2/repository/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar:/Users/emoleumassi/.m2/repository/org/apache/maven/maven-artifact/2.0/maven-artifact-2.0.jar:/Users/emoleumassi/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-8/plexus-container-default-1.0-alpha-8.jar:/Users/emoleumassi/.m2/repository/junit/junit/4.13.2/junit-4.13.2.jar:/Users/emoleumassi/.m2/repository/org/hamcrest/hamcrest-core/2.2/hamcrest-core-2.2.jar:/Users/emoleumassi/.m2/repository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/Users/emoleumassi/.m2/repository/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar:/Users/emoleumassi/.m2/repository/ch/qos/logback/logback-classic/1.2.9/logback-classic-1.2.9.jar:/Users/emoleumassi/.m2/repository/ch/qos/logback/logback-core/1.2.9/logback-core-1.2.9.jar:/Users/emoleumassi/.m2/repository/com/fasterxml/jackson/module/jackson-module-jaxb-annotations/2.13.1/jackson-module-jaxb-annotations-2.13.1.jar:/Users/emoleumassi/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.1/jackson-annotations-2.13.1.jar:/Users/emoleumassi/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.1/jackson-core-2.13.1.jar:/Users/emoleumassi/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.1/jackson-databind-2.13.1.jar:/Users/emoleumassi/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar:/Users/emoleumassi/.m2/repository/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/2.6.2/spring-boot-starter-data-jpa-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-aop/2.6.2/spring-boot-starter-aop-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/aspectj/aspectjweaver/1.9.7/aspectjweaver-1.9.7.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/2.6.2/spring-boot-starter-jdbc-2.6.2.jar:/Users/emoleumassi/.m2/repository/com/zaxxer/HikariCP/4.0.3/HikariCP-4.0.3.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-jdbc/5.3.14/spring-jdbc-5.3.14.jar:/Users/emoleumassi/.m2/repository/jakarta/transaction/jakarta.transaction-api/1.3.3/jakarta.transaction-api-1.3.3.jar:/Users/emoleumassi/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar:/Users/emoleumassi/.m2/repository/org/hibernate/hibernate-core/5.6.3.Final/hibernate-core-5.6.3.Final.jar:/Users/emoleumassi/.m2/repository/org/jboss/logging/jboss-logging/3.4.2.Final/jboss-logging-3.4.2.Final.jar:/Users/emoleumassi/.m2/repository/net/bytebuddy/byte-buddy/1.11.22/byte-buddy-1.11.22.jar:/Users/emoleumassi/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/emoleumassi/.m2/repository/org/jboss/jandex/2.2.3.Final/jandex-2.2.3.Final.jar:/Users/emoleumassi/.m2/repository/com/fasterxml/classmate/1.5.1/classmate-1.5.1.jar:/Users/emoleumassi/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.1.2.Final/hibernate-commons-annotations-5.1.2.Final.jar:/Users/emoleumassi/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.5/jaxb-runtime-2.3.5.jar:/Users/emoleumassi/.m2/repository/org/glassfish/jaxb/txw2/2.3.5/txw2-2.3.5.jar:/Users/emoleumassi/.m2/repository/com/sun/istack/istack-commons-runtime/3.0.12/istack-commons-runtime-3.0.12.jar:/Users/emoleumassi/.m2/repository/com/sun/activation/jakarta.activation/1.2.2/jakarta.activation-1.2.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/data/spring-data-jpa/2.6.0/spring-data-jpa-2.6.0.jar:/Users/emoleumassi/.m2/repository/org/springframework/data/spring-data-commons/2.6.0/spring-data-commons-2.6.0.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-orm/5.3.14/spring-orm-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-context/5.3.14/spring-context-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-tx/5.3.14/spring-tx-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-beans/5.3.14/spring-beans-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-aspects/5.3.14/spring-aspects-5.3.14.jar:/Users/emoleumassi/.m2/repository/mysql/mysql-connector-java/8.0.27/mysql-connector-java-8.0.27.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter/2.6.2/spring-boot-starter-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.6.2/spring-boot-starter-logging-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.17.0/log4j-to-slf4j-2.17.0.jar:/Users/emoleumassi/.m2/repository/org/apache/logging/log4j/log4j-api/2.17.0/log4j-api-2.17.0.jar:/Users/emoleumassi/.m2/repository/org/slf4j/jul-to-slf4j/1.7.32/jul-to-slf4j-1.7.32.jar:/Users/emoleumassi/.m2/repository/org/yaml/snakeyaml/1.29/snakeyaml-1.29.jar:/Users/emoleumassi/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-core/5.3.14/spring-core-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-jcl/5.3.14/spring-jcl-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-security/2.6.2/spring-boot-starter-security-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-aop/5.3.14/spring-aop-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/security/spring-security-config/5.6.1/spring-security-config-5.6.1.jar:/Users/emoleumassi/.m2/repository/org/springframework/security/spring-security-core/5.6.1/spring-security-core-5.6.1.jar:/Users/emoleumassi/.m2/repository/org/springframework/security/spring-security-crypto/5.6.1/spring-security-crypto-5.6.1.jar:/Users/emoleumassi/.m2/repository/org/springframework/security/spring-security-web/5.6.1/spring-security-web-5.6.1.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-expression/5.3.14/spring-expression-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/spring-web/5.3.14/spring-web-5.3.14.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.6.2/spring-boot-starter-tomcat-2.6.2.jar:/Users/emoleumassi/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/emoleumassi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.56/tomcat-embed-core-9.0.56.jar:/Users/emoleumassi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.56/tomcat-embed-el-9.0.56.jar:/Users/emoleumassi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.56/tomcat-embed-websocket-9.0.56.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-devtools/2.6.2/spring-boot-devtools-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot/2.6.2/spring-boot-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.6.2/spring-boot-autoconfigure-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/2.6.2/spring-boot-starter-actuator-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/2.6.2/spring-boot-actuator-autoconfigure-2.6.2.jar:/Users/emoleumassi/.m2/repository/org/springframework/boot/spring-boot-actuator/2.6.2/spring-boot-actuator-2.6.2.jar:/Users/emoleumassi/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.13.1/jackson-datatype-jsr310-2.13.1.jar:/Users/emoleumassi/.m2/repository/io/micrometer/micrometer-core/1.8.1/micrometer-core-1.8.1.jar:/Users/emoleumassi/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.12/HdrHistogram-2.1.12.jar:/Users/emoleumassi/.m2/repository/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.jar:/Users/emoleumassi/.m2/repository/org/projectlombok/lombok/1.18.16/lombok-1.18.16.jar:/Users/emoleumassi/.m2/repository/org/projectlombok/lombok-mapstruct-binding/0.2.0/lombok-mapstruct-binding-0.2.0.jar com.kazi.Application
19:21:19.040 [Thread-0] DEBUG org.springframework.boot.devtools.restart.classloader.RestartClassLoader - Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@32d703c9

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.2)

2022-01-24 19:21:19.677  INFO 28392 --- [  restartedMain] com.kazi.Application                     : Starting Application using Java 11.0.11 on FVFFF491Q05N.fritz.box with PID 28392 (/kazi/kazi-core/target/classes started by in //kazi)
2022-01-24 19:21:19.678  INFO 28392 --- [  restartedMain] com.kazi.Application                     : No active profile set, falling back to default profiles: default
2022-01-24 19:21:19.743  INFO 28392 --- [  restartedMain] o.s.b.devtools.restart.ChangeableUrls    : The Class-Path manifest attribute in //.m2/repository/org/liquibase/liquibase-core/4.5.0/liquibase-core-4.5.0.jar referenced one or more files that do not exist: file://.m2/repository/org/liquibase/liquibase-core/4.5.0/snakeyaml-1.27.jar
2022-01-24 19:21:19.745  INFO 28392 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-01-24 19:21:19.745  INFO 28392 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-01-24 19:21:21.125  INFO 28392 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-01-24 19:21:21.132  INFO 28392 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-01-24 19:21:21.132  INFO 28392 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]
2022-01-24 19:21:21.208  INFO 28392 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-01-24 19:21:21.209  INFO 28392 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1464 ms
2022-01-24 19:21:21.656  INFO 28392 --- [  restartedMain] .s.s.UserDetailsServiceAutoConfiguration : 

Using generated security password: 6b57bd8f-9f75-40b5-8805-d33182a6782f

2022-01-24 19:21:21.719  INFO 28392 --- [  restartedMain] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@585f2fd, org.springframework.security.web.context.SecurityContextPersistenceFilter@217e757f, org.springframework.security.web.header.HeaderWriterFilter@54ef1e31, org.springframework.security.web.csrf.CsrfFilter@1323ecfd, org.springframework.security.web.authentication.logout.LogoutFilter@50c74237, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@31cfd78a, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@175a6ba7, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@74ce9809, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@1143ca59, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@4de8bf20, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@272d7d98, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@7bd095cb, org.springframework.security.web.session.SessionManagementFilter@7d64f793, org.springframework.security.web.access.ExceptionTranslationFilter@8fd5915, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@53681a29]
2022-01-24 19:21:21.782  INFO 28392 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2022-01-24 19:21:21.835  INFO 28392 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2022-01-24 19:21:21.856  INFO 28392 --- [  restartedMain] com.kazi.Application                     : Started Application in 2.798 seconds (JVM running for 3.673)

The application start successfully but the tables haven't created. I tried it with ddl-auto: create und have the same problem.

I think the application.yml isn't load.

The location: 在此处输入图像描述

I think no Datasource in this app.

@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class) 

try this

@EnableAutoConfiguration 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM