maven tomcat7:run configure datasource



我有一个多模块 maven 项目,我想将其与 tomcat7 maven 插件一起使用并启动它:

mvn tomcat7:run

但是我不知道如何配置 jndi 数据源。
我试着把我的绒球放进去.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>

在上下文中.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>

但它不起作用...如何注册 jndi 数据源?

错误消息是什么?用:

<plugin>
 <groupId>org.apache.tomcat.maven</groupId>
 <artifactId>tomcat7-maven-plugin</artifactId>
 <version>2.2</version>
 <configuration>
      <contextFile>tomcat/context.xml</contextFile>
 </configuration>
</plugin>

也许您的 jdbc 驱动程序在类路径中不可用?

尝试将他添加到插件依赖项中

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

最新更新