Ah, mystery solved. Looking at the code, more specifically to use properties for a given DataSource Cayenne would expect you to specify at least DB URL and DB driver. Username/password are optional.
Andrus > On Jan 18, 2018, at 11:46 AM, Nikita Timofeev <ntimof...@objectstyle.com> > wrote: > > Hi all, > > Made some research, and here is what I've found. > > Cayenne do switch to System properties (defined via -D or with DI > binding) automatically but it do so only when all properties are > defined. > > So this code will work as expected, and use overridden DataSource properties: > > ServerRuntime cayenneRuntime = > ServerRuntime.builder().addConfig("cayenne-project.xml") > .addModule(binder -> ServerModule.contributeProperties(binder) > .put(Constants.JDBC_DRIVER_PROPERTY, "com.mysql.jdbc.Driver") > .put(Constants.JDBC_URL_PROPERTY, > "jdbc:mysql://localhost:3306/test") > .put(Constants.JDBC_USERNAME_PROPERTY, "user") > .put(Constants.JDBC_PASSWORD_PROPERTY, "password")) > .build(); > > While this will ignore password and use DataSource properties from XML: > > ServerRuntime cayenneRuntime = > ServerRuntime.builder().addConfig("cayenne-project.xml") > .addModule(binder -> ServerModule.contributeProperties(binder) > .put(Constants.JDBC_PASSWORD_PROPERTY, "password")) > .build(); > > I will add some information to logs, so at least it wouldn't be > surprising as it is now. > But maybe we should change this to enable override of separate properties. > > On Thu, Jan 18, 2018 at 8:27 AM, Andrus Adamchik <and...@objectstyle.org> > wrote: >> >> >>> On Jan 17, 2018, at 11:05 PM, Pascal Robert <prob...@druide.com> wrote: >>> >>> Ahhh… If I change the factory in the node definition to >>> org.apache.cayenne.configuration.server.PropertyDataSourceFactory, it does >>> read the command-line properties. >> >> That should sorta happen automatically. We are still looking why it doesn't. >> >> Andrus >> > > > > -- > Best regards, > Nikita Timofeev