问题
I have a multimodule maven project, and I want to use it with tomcat7 maven plugin and start it with:
mvn tomcat7:run
But I can't figure out how to configure a jndi datasource.
I've tried to put in my pom.xml:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<contextFile>tomcat/context.xml</contextFile>
</configuration>
</plugin>
and in the context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/AppealDS" url="jdbc:hsqldb:file:database/appeal"
driverClassName="org.hsqldb.jdbcDriver" username="appeal"
password="appeal" auth="Container" type="javax.sql.DataSource"
maxActive="3" maxIdle="2" maxWait="10000" />
</Context>
But it doesn't work...How can I register the jndi datasource?
回答1:
What is the error message? Use:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<contextFile>tomcat/context.xml</contextFile>
</configuration>
</plugin>
Maybe your jdbc driver is not available in the classpath?
Try adding him in the plugin dependency
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<contextFile>tomcat/context.xml</contextFile>
</configuration>
<dependencies>
<dependency>
here your hsql version
</dependency>
</dependencies>
</plugin>
来源:https://stackoverflow.com/questions/22118698/maven-tomcat7run-configure-datasource