1

I'd like to set up a one-liner to deploy my webapp in TomEE using Maven TomEE plugin. Normally, I'd just put the .war artifact in <tomee-home>/webapps/ and set up <tomee-home>/conf/system.properties in a way like this:

myAppDS.jdbcUrl = jdbc:mysql://<host>:<port>/<schemaName>
myAppDS.password = <db user password>
myAppDS.userName = <db user name>  

But how can I set these properties in command line using maven tomee:run?

cidra
  • 374
  • 1
  • 4
  • 16

1 Answers1

1

I would prefer the tomee.xml configuration to declare resources while using the TomEE Maven Plugin.

You can define your datasource in the TomEE Maven Plugin (similar to conf/tomee.xml in a standalone deployment) as follows:

<?xml version="1.0" encoding="UTF-8"?>
<tomee>
    <Resource id="myDS" type="javax.sql.DataSource">
        JtaManaged = true
        driverClassName = ${jdbc.driver}
        url = ${jdbc.url}
        username = ${jdbc.user}
        password = ${jdbc.pw}
    </Resource>
</tomee>

and reference the folder containing the tomee.xml via <config> in the TomEE Maven Plugin <configuration> section.

Alternative would be to use a resources.xml in WEB-INF of your web application:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <Resource id="myDS" type="javax.sql.DataSource">
        JtaManaged = true
      
        driverClassName = ${jdbc.driver}
        url = ${jdbc.url}
        username = ${jdbc.user}
        password = ${jdbc.pw}
    </Resource>
</resources>
rzo1
  • 5,561
  • 3
  • 25
  • 64
  • I have already defined WEB-INF/resources.xml, but I'd like to set some parameters in the command line. Could i instead use the ${...} notation in resources.xml and substitute with CLI parameters? – cidra Mar 21 '22 at 11:59
  • If you are building the project beforehand you could use Maven resource filtering to adjust the values as desired – rzo1 Mar 21 '22 at 20:06