davidvera
davidvera

Reputation: 1489

Can't load webservice application.properties when using spring cloud config server

I have a spring cloud config server running with github and a web service managing users. Current version used for this test project are :

And I have a service using this config server:

server.port=${PORT:0}
spring.application.name=users-ws

# mysql configuration
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.url=jdbc:mysql://localhost:3306/users?createDatabaseIfNotExist=true
spring.jpa.hibernate.ddl-auto = create
# display sql requests
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true

# logging configuration
logging.level.root=WARN
logging.level.sql=INFO
logging.level.web=WARN
logging.level.fr.dsidiff=WARN
logging.level.org.hibernate.SQL=TRACE
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

logging.file.name=webapps-logs/users-ws.logs
logging.logback.rollingpolicy.file-name-pattern=webapps-logs/archived/users-ws.%d{yyyy-MM-dd}.%i.log
logging.logback.rollingpolicy.max-history=5
logging.logback.rollingpolicy.max-file-size=250MB

logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %green([%thread]) %highlight(%level)  %logger{36} - %msg%n
logging.pattern.file=%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n

token.expirationTime=3600000
users.ws.accountLock=2

I also added a bootstrap.properties (even if optional):

spring.config.name=springCloudConfigServer
spring.config.import=optional:configserver:http://localhost:8012

Now on the other side, i configured my config server to get configuration from remote git repo:

spring.application.name=springCloudConfigServer
server.port=8012

# local or repo git
# github
spring.profiles.active=git
spring.cloud.config.server.git.uri=https://github.com/me/config-server
[email protected]
spring.cloud.config.server.git.password=****mytoken***

spring.cloud.config.server.git.clone-on-start=true
spring.cloud.config.server.git.force-pull=true
spring.cloud.config.server.git.default-label=master
#https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html
spring.cloud.config.server.git.search-paths=dsipilot**

I pushed an application.properties on my remote server containing some basic params i want to override for test purpose, for example, I changed the following information:

token.expirationTime=7200000
users.ws.accountLock=5

My issue is that on startup, my users webservice crashes:

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

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

Apparently, the application can't start because it didn't find any datasource. As a matter of fact i didn't put data source on git remote application.properties but it is still in the users webservice application.properties.

Do i have to put all my properties to make my application run correctly ? ideally, i'd like to have immutable params. Maybe not the database but application name for example, the ports, etc.

I can access the following URL to read the remote application.properties: http://localhost:8012/users-ws/default

Is there any configuration I forget ?

Upvotes: 0

Views: 103

Answers (1)

davidvera
davidvera

Reputation: 1489

I replaced

spring.config.import=optional:configserver:http://localhost:8012

With this:

spring.cloud.config.uri=http://localhost:8082

Upvotes: 0

Related Questions