IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

Could not resolve placeholder in string value


Sujet :

Spring Java

  1. #1
    Membre du Club
    Homme Profil pro
    Inscrit en
    Juillet 2013
    Messages
    114
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tchad

    Informations forums :
    Inscription : Juillet 2013
    Messages : 114
    Points : 47
    Points
    47
    Par défaut Could not resolve placeholder in string value
    Bonjour,

    J'essaie d'utiliser les propriétés d'un fichier .properties , mais cela ne semble pas fonctionner.

    voici mon code
    Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    	<modelVersion>4.0.0</modelVersion>
     
    	<groupId>vn.ifi</groupId>
    	<artifactId>config-service</artifactId>
    	<version>0.0.1-SNAPSHOT</version>
    	<packaging>jar</packaging>
     
    	<name>a-bourse-config-service</name>
    	<description>Demo project for Spring Boot</description>
     
    	<parent>
    		<groupId>org.springframework.boot</groupId>
    		<artifactId>spring-boot-starter-parent</artifactId>
    		<version>2.0.4.RELEASE</version>
    		<relativePath/> <!-- lookup parent from repository -->
    	</parent>
     
    	<properties>
    		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    		<java.version>1.8</java.version>
    		<spring-cloud.version>Finchley.SR1</spring-cloud.version>
    	</properties>
     
    	<dependencies>
    		<dependency>
    			<groupId>org.springframework.cloud</groupId>
    			<artifactId>spring-cloud-config-server</artifactId>
    		</dependency>
     
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-test</artifactId>
    			<scope>test</scope>
    		</dependency>
    	</dependencies>
     
    	<dependencyManagement>
    		<dependencies>
    			<dependency>
    				<groupId>org.springframework.cloud</groupId>
    				<artifactId>spring-cloud-dependencies</artifactId>
    				<version>${spring-cloud.version}</version>
    				<type>pom</type>
    				<scope>import</scope>
    			</dependency>
    		</dependencies>
    	</dependencyManagement>
     
    	<build>
    		<plugins>
    			<plugin>
    				<groupId>org.springframework.boot</groupId>
    				<artifactId>spring-boot-maven-plugin</artifactId>
    			</plugin>
    		</plugins>
    	</build>
     
     
    </project>

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    package vn.ifi;
     
    import java.util.stream.Stream;
     
     
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.ApplicationContext;
     
     
    import vn.ifi.entities.Societe;
    import vn.ifi.entities.dao.SocieteRepository;
     
    @SpringBootApplication
    public class ABourseSocieteServiceApplication {
     
    	public static void main(String[] args) {
    		ApplicationContext ctx=SpringApplication.run(ABourseSocieteServiceApplication.class, args);
    		SocieteRepository societeRepository=ctx.getBean(SocieteRepository.class);
    		Stream.of("VIETNAM HAIR STAR COMPANY","LINYECO","UPS").forEach(s->societeRepository.save(new Societe(s)));
    		societeRepository.findAll().forEach(s->System.out.println(s.getNomSociete()));
    	}
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    package vn.ifi.services;
     
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
     
    @RestController
    public class BourseRestService {
    	@Value("${me}")
    	private String message;
    	@RequestMapping("/messages")
    	public String tellMe() {
    		return message;
     
    	}
     
    }
    Code x : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    2018-09-04 04:11:20.848  INFO 17369 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@33d512c1: startup date [Tue Sep 04 04:11:20 CEST 2018]; root of context hierarchy
    2018-09-04 04:11:22.710  INFO 17369 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
    2018-09-04 04:11:23.035  INFO 17369 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$50c4f645] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    
      .   ____          _            __ _ _
     /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
     \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
      '  |____| .__|_| |_|_| |_\__, | / / / /
     =========|_|==============|___/=/_/_/_/
     :: Spring Boot ::        (v2.0.4.RELEASE)
    
    2018-09-04 04:11:25.417  INFO 17369 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
    2018-09-04 04:11:30.532  INFO 17369 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=application, profiles=[default], label=null, version=a67dc3dc12c3a2e81901d9445b254868469db0be, state=null
    2018-09-04 04:11:30.535  INFO 17369 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='file:///home/brahim/my-config/application.properties'}]}
    2018-09-04 04:11:30.583  INFO 17369 --- [           main] vn.ifi.ABourseSocieteServiceApplication  : No active profile set, falling back to default profiles: default
    2018-09-04 04:11:30.721  INFO 17369 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@35645047: startup date [Tue Sep 04 04:11:30 CEST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@33d512c1
    2018-09-04 04:11:38.576  INFO 17369 --- [           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]]
    2018-09-04 04:11:40.521  INFO 17369 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=920f0185-d161-3cb2-b1a6-ae27e5389794
    2018-09-04 04:11:40.978  INFO 17369 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
    2018-09-04 04:11:41.699  INFO 17369 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration' of type [org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration$$EnhancerBySpringCGLIB$$fb16b176] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2018-09-04 04:11:42.752  INFO 17369 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$34aaf348] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2018-09-04 04:11:43.048  INFO 17369 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$b42b407a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2018-09-04 04:11:43.241  INFO 17369 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$50c4f645] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2018-09-04 04:11:46.755  INFO 17369 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
    2018-09-04 04:11:47.176  INFO 17369 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
    2018-09-04 04:11:47.177  INFO 17369 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.32
    2018-09-04 04:11:47.230  INFO 17369 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib]
    2018-09-04 04:11:48.143  INFO 17369 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
    2018-09-04 04:11:48.145  INFO 17369 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 17424 ms
    2018-09-04 04:11:49.470  WARN 17369 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
    2018-09-04 04:11:49.472  INFO 17369 --- [ost-startStop-1] 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.
    2018-09-04 04:11:49.524  INFO 17369 --- [ost-startStop-1] c.netflix.config.DynamicPropertyFactory  : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@631db9fa
    2018-09-04 04:11:55.427  INFO 17369 --- [ost-startStop-1] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
    2018-09-04 04:11:56.961  INFO 17369 --- [ost-startStop-1] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
    2018-09-04 04:12:01.374  INFO 17369 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
    2018-09-04 04:12:01.376  INFO 17369 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webMvcMetricsFilter' to: [/*]
    2018-09-04 04:12:01.380  INFO 17369 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
    2018-09-04 04:12:01.381  INFO 17369 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
    2018-09-04 04:12:01.382  INFO 17369 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
    2018-09-04 04:12:01.383  INFO 17369 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpTraceFilter' to: [/*]
    2018-09-04 04:12:01.383  INFO 17369 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
    2018-09-04 04:12:02.319  INFO 17369 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
    2018-09-04 04:12:03.396  INFO 17369 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
    2018-09-04 04:12:03.798  INFO 17369 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
    2018-09-04 04:12:03.944  INFO 17369 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    	name: default
    	...]
    2018-09-04 04:12:04.519  INFO 17369 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.17.Final}
    2018-09-04 04:12:04.527  INFO 17369 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
    2018-09-04 04:12:04.876  INFO 17369 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
    2018-09-04 04:12:05.670  INFO 17369 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
    2018-09-04 04:12:09.516  INFO 17369 --- [           main] o.h.t.schema.internal.SchemaCreatorImpl  : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@3a5b7d7e'
    2018-09-04 04:12:09.530  INFO 17369 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
    2018-09-04 04:12:09.623  WARN 17369 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bourseRestService': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'me' in value "${me}"
    2018-09-04 04:12:09.628  INFO 17369 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
    2018-09-04 04:12:09.637  INFO 17369 --- [           main] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed drop of schema as part of SessionFactory shut-down'
    2018-09-04 04:12:09.732  INFO 17369 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
    2018-09-04 04:12:09.764  INFO 17369 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
    2018-09-04 04:12:09.767  INFO 17369 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
    2018-09-04 04:12:09.948  INFO 17369 --- [           main] ConditionEvaluationReportLoggingListener : 
    
    Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
    2018-09-04 04:12:10.002 ERROR 17369 --- [           main] o.s.boot.SpringApplication               : Application run failed
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bourseRestService': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'me' in value "${me}"
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:378) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    	at vn.ifi.ABourseSocieteServiceApplication.main(ABourseSocieteServiceApplication.java:18) [classes/:na]
    Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'me' in value "${me}"
    	at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:839) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1083) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:583) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    	... 17 common frames omitted
    ou bref;
    Could not resolve placeholder 'me' in value "${me}"
    Je manque évidemment quelque chose, mais je ne peux pas savoir quoi.

    S'il vous plaît si vous avez besoin de plus de détails, je suis a votre disposition

  2. #2
    Membre du Club
    Homme Profil pro
    Inscrit en
    Juillet 2013
    Messages
    114
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tchad

    Informations forums :
    Inscription : Juillet 2013
    Messages : 114
    Points : 47
    Points
    47
    Par défaut
    je reviens encore pour diminuer le champ du probleme.
    au fait quand je met en commentaire la ligne ou bien j'enleve le symbole dollarle serveur se redemarre donc est-ce que j'appliaue mal la nottation @Value()?

  3. #3
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Bonjour,

    Tu dois ajouter les fichiers properties dans ton build resources:

    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
    <build>
    	<resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
    		<plugins>
    			<plugin>
    				<groupId>org.springframework.boot</groupId>
    				<artifactId>spring-boot-maven-plugin</artifactId>
    			</plugin>
    		</plugins>
    </build>

    A+.

  4. #4
    Membre du Club
    Homme Profil pro
    Inscrit en
    Juillet 2013
    Messages
    114
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tchad

    Informations forums :
    Inscription : Juillet 2013
    Messages : 114
    Points : 47
    Points
    47
    Par défaut
    Merci pour la reponse
    j'ai ajouté mais toujours la même chose
    Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    	<modelVersion>4.0.0</modelVersion>
     
    	<groupId>vn.ifi</groupId>
    	<artifactId>societe-service</artifactId>
    	<version>0.0.1-SNAPSHOT</version>
    	<packaging>jar</packaging>
     
    	<name>a-bourse-societe-service</name>
    	<description>Demo project for Spring Boot</description>
     
    	<parent>
    		<groupId>org.springframework.boot</groupId>
    		<artifactId>spring-boot-starter-parent</artifactId>
    		<version>2.0.4.RELEASE</version>
    		<relativePath/> <!-- lookup parent from repository -->
    	</parent>
     
    	<properties>
    		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    		<java.version>1.8</java.version>
    		<spring-cloud.version>Finchley.SR1</spring-cloud.version>
    		<start-class>vn.ifi.ABourseSocieteServiceApplication</start-class>
    	</properties>
     
    	<dependencies>
     
     
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-amqp</artifactId>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-data-jpa</artifactId>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-data-rest</artifactId>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-web</artifactId>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.cloud</groupId>
    			<artifactId>spring-cloud-starter-config</artifactId>
    		</dependency>
     
    				<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
     
    		<dependency>
    			<groupId>org.springframework.cloud</groupId>
    			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    		</dependency>
    		<!--  -->
    		<dependency>
    			<groupId>com.h2database</groupId>
    			<artifactId>h2</artifactId>
    			<scope>runtime</scope>
    		</dependency>
     
     
     
    		<dependency>
    			<groupId>mysql</groupId>
    			<artifactId>mysql-connector-java</artifactId>
    			<scope>runtime</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-test</artifactId>
    			<scope>test</scope>
    		</dependency>
    	</dependencies>
     
    <repositories>
        <repository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>
     
    	<dependencyManagement>
    		<dependencies>
    			<dependency>
    				<groupId>org.springframework.cloud</groupId>
    				<artifactId>spring-cloud-dependencies</artifactId>
    				<version>${spring-cloud.version}</version>
    				<type>pom</type>
    				<scope>import</scope>
    			</dependency>
    		</dependencies>
    	</dependencyManagement>
     
    	<build>
     
    	<resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
    		<plugins>
    			<plugin>
    				<groupId>org.springframework.boot</groupId>
    				<artifactId>spring-boot-maven-plugin</artifactId>
     
    			</plugin>
    		</plugins>
     
    </build>
     
    </project>

  5. #5
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Tu dois avoir un bean PropertySourcesPlaceholderConfigurer. Je ne sais pas si tu as une configuration dans un xml, sinon dans la classe ABourseSocieteServiceApplication:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    @Bean
    public static PropertySourcesPlaceholderConfigurer properties() {
        return new PropertySourcesPlaceholderConfigurer();
    }
    Dans ton controler
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    @PropertySource("classpath:leFichierProperties.properties") // si le fichier se trouve directement dans src/main/resources
    @RestController
    public class BourseRestService
    A+.

  6. #6
    Membre du Club
    Homme Profil pro
    Inscrit en
    Juillet 2013
    Messages
    114
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tchad

    Informations forums :
    Inscription : Juillet 2013
    Messages : 114
    Points : 47
    Points
    47
    Par défaut
    je demande d'excuse d'abuser de votre temps.
    En effet, j'ai ajoute comme tu as suggere mais la meme erreur insiste toujours
    voici mon code apres modification;

    classe BourseRestService
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    package vn.ifi.services;
     
     
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.context.annotation.PropertySource;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    @PropertySource("classpath:boostrap.properties")
    @RestController
    public class BourseRestService {
    	@Value("${me}")
    	private String message;
    	@RequestMapping("/messages")
    	public String tellMe() {
    		return message;
     
    	}
     
    }
    et la classe applicative
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    package vn.ifi;
     
    import java.util.stream.Stream;
     
     
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
     
    import vn.ifi.entities.Societe;
    import vn.ifi.entities.dao.SocieteRepository;
     
    @SpringBootApplication
    public class ABourseSocieteServiceApplication {
     
    	public static void main(String[] args) {
    		ApplicationContext ctx=SpringApplication.run(ABourseSocieteServiceApplication.class, args);
    		SocieteRepository societeRepository=ctx.getBean(SocieteRepository.class);
    		Stream.of("VIETNAM HAIR STAR COMPANY","LINYECO","UPS").forEach(s->societeRepository.save(new Societe(s)));
    		societeRepository.findAll().forEach(s->System.out.println(s.getNomSociete()));
    	}
    	@Bean
    	public static PropertySourcesPlaceholderConfigurer properties() {
    	    return new PropertySourcesPlaceholderConfigurer();
    	}
    }

  7. #7
    Expert confirmé
    Homme Profil pro
    Inscrit en
    Septembre 2006
    Messages
    2 937
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 2 937
    Points : 4 358
    Points
    4 358
    Par défaut
    @Value est dans votre @Controller qui dépend du servlet context, et vous avez mis le PropertySourcesPlaceholderConfigurer dans l'application context.

  8. #8
    Membre du Club
    Homme Profil pro
    Inscrit en
    Juillet 2013
    Messages
    114
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tchad

    Informations forums :
    Inscription : Juillet 2013
    Messages : 114
    Points : 47
    Points
    47
    Par défaut
    Citation Envoyé par JeitEmgie Voir le message
    @Value est dans votre @Controller qui dépend du servlet context, et vous avez mis le PropertySourcesPlaceholderConfigurer dans l'application context.
    s'il vous plait je n'ai pas compris, pouvez-vous me détailler un peu?

  9. #9
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Citation Envoyé par JeitEmgie Voir le message
    @Value est dans votre @Controller qui dépend du servlet context, et vous avez mis le PropertySourcesPlaceholderConfigurer dans l'application context.
    Après reflexion, je ne pense même pas qu'il a besoin d'un PropertySourcesPlaceholderConfigurer pour le moment.

    @koreimy, utilise d'abord le minimum de code.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    @SpringBootApplication
    public class ABourseSocieteServiceApplication {
     
    	public static void main(String[] args) {
    		SpringApplication.run(ABourseSocieteServiceApplication.class, args);
    	}
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    @PropertySource("classpath:boostrap.properties")
    @RestController
    public class BourseRestService {
    	@Value("${me}")
    	private String message;
    	@RequestMapping("/messages")
    	public String tellMe() {
    		return message;
     
    	}
     
    }
    Ensuite, dans le fichier boostrap.properties, tu as la clé me?
    Essaie de faire un mvn clean install avant de lancer l'appli.

    A+.

  10. #10
    Expert confirmé
    Homme Profil pro
    Inscrit en
    Septembre 2006
    Messages
    2 937
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 2 937
    Points : 4 358
    Points
    4 358
    Par défaut
    Citation Envoyé par andry.aime Voir le message
    Après reflexion, je ne pense même pas qu'il a besoin d'un PropertySourcesPlaceholderConfigurer pour le moment.
    c'est possible, Spring boot fait beaucoup par défaut,
    mais les raisons pour lesquelles un @Value ne fonctionne pas sans message clair dans les logs, tournent toujours autour des mêmes choses :
    pas de PropertySourcesPlaceholderConfigurer dans le bon contexte, classes non scannées

    Mais en relisant le post de début il y a bien un message "could not resolve" donc le problème est simplement que "me" n'est pas défini dans les fichiers de propriétés scannés.

  11. #11
    Membre du Club
    Homme Profil pro
    Inscrit en
    Juillet 2013
    Messages
    114
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tchad

    Informations forums :
    Inscription : Juillet 2013
    Messages : 114
    Points : 47
    Points
    47
    Par défaut
    effectivement je n'ai pas défini "me" dans le fichier boostrap mais j'ai défini dans un autre fichier dans lequel ce trouve les propriétés propres à ce service que j'ai défini comme suit:

    le contenu de boostrap
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    spring.application.name=societe-service
    spring.cloud.config.uri=http://localhost:8888
    et le fichier societe-service
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    server.port=8080
    me=me@google.fr
    par ailleurs effectivement quand je défini "me" dans boostrap ça marche .

    Citation Envoyé par andry.aime Voir le message
    mvn clean install avant de lancer l'appli.
    comment on applique?

  12. #12
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Citation Envoyé par koreimy Voir le message
    Citation Envoyé par andry.aime Voir le message
    mvn clean install avant de lancer l'appli.
    comment on applique?
    Plus la peine maintenant, j'ai simplement pensé que tes changements n'étaient pas prise en compte et qu'il fallait faire une build. Pour le faire, soit tu le lances la commande dans une console dans le répertoire de ton projet, soit depuis ton IDE.

    A+.

  13. #13
    Nouveau Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2020
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Deux Sèvres (Poitou Charente)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2020
    Messages : 1
    Points : 1
    Points
    1
    Par défaut Problème similaire
    Bonjour,

    J'ai eu le même genre de soucis, mon problème venait de l'architecture de mon projet, en effet mon code source n'était pas sous main/src/java/... ce qui ne permettait pas à spring boot de fonctionner de manière automatique.

Discussions similaires

  1. could not resolve property
    Par *alexandre* dans le forum Hibernate
    Réponses: 1
    Dernier message: 30/10/2006, 13h44
  2. [Oracle] could not resolve service name
    Par navis84 dans le forum PHP & Base de données
    Réponses: 1
    Dernier message: 21/07/2006, 11h12
  3. [Database link] TNS:could not resolve service name
    Par sleepy2002 dans le forum Oracle
    Réponses: 3
    Dernier message: 07/03/2006, 05h22
  4. Réponses: 11
    Dernier message: 29/06/2005, 11h36
  5. TNS:listener could not resolve SERVICE_NAME given in connect
    Par Sinclair dans le forum Administration
    Réponses: 15
    Dernier message: 20/08/2003, 17h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo