gpt4 book ai didi

java - 在 Spring Boot 中更新应用程序的配置

转载 作者:太空宇宙 更新时间:2023-11-04 10:24:03 24 4
gpt4 key购买 nike

当我运行 Spring Boot 应用程序时,在 Spring Boot 错误中更新应用程序的配置。

maven构建成功,但错误依旧。

我应该怎样做才能克服这个错误?

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

2018-06-08 12:45:36.422 INFO 8904 --- [ main] com.lankydan.Application : Starting Application on GH-6C9HNH2 with PID 8904 (C:\Users\E080978\Downloads\Maven\spring-boot-hateoas-master\target\classes started by E080978 in C:\Users\E080978\Downloads\Maven\spring-boot-hateoas-master)
2018-06-08 12:45:36.426 INFO 8904 --- [ main] com.lankydan.Application : No active profile set, falling back to default profiles: default
2018-06-08 12:45:36.484 INFO 8904 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2805c96b: startup date [Fri Jun 08 12:45:36 IST 2018]; root of context hierarchy
2018-06-08 12:45:37.897 INFO 8904 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$3a19c841] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-06-08 12:45:38.652 INFO 8904 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8090 (http)
2018-06-08 12:45:38.672 INFO 8904 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-06-08 12:45:38.673 INFO 8904 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.20
2018-06-08 12:45:38.818 INFO 8904 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-06-08 12:45:38.818 INFO 8904 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2337 ms
2018-06-08 12:45:39.020 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-06-08 12:45:39.025 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-06-08 12:45:39.025 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-06-08 12:45:39.026 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-06-08 12:45:39.026 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-06-08 12:45:39.075 WARN 8904 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Unsatisfied dependency expressed through method 'dataSource' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Could not bind properties to 'DataSourceProperties': prefix=spring.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource.password' to java.lang.String
2018-06-08 12:45:39.077 INFO 8904 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-06-08 12:45:39.098 INFO 8904 --- [ main] utoConfigurationReportLoggingInitializer :

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-06-08 12:45:39.103 ERROR 8904 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

***************************
APPLICATION FAILED TO START
***************************

Description:

Binding to target [Bindable@6bff19ff type = java.lang.String, value = 'provided', annotations = array<Annotation>[[empty]]] failed:

Property: spring.datasource.password
Value: ${password}
Origin: class path resource [application.properties]:7:28
Reason: Could not resolve placeholder 'password' in value "${password}"

Action:

Update your application's configuration

最佳答案

您必须为您的 Maven 资源插件打开过滤。您必须添加<filtering>标记到您的 POM 并将其设置为 true

${password}在“处理资源”阶段,变量可能需要由 maven 替换为真实密码

有关更多信息,请参阅:

https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

关于java - 在 Spring Boot 中更新应用程序的配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50755379/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com