mavenapache-tomeetomee-8

Set TomEE conf/system.properties properties from command line using TomEE Maven Plugin


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?


Solution

  • 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>