Java 如何在Tomcat8+;焊接3.0(CDI 2.0)?

Java 如何在Tomcat8+;焊接3.0(CDI 2.0)?,java,maven,tomcat,cdi,weld,Java,Maven,Tomcat,Cdi,Weld,我已经在Tomcat中安装了Weld/CDI,并且工作正常,但在启动时,它说没有启用事务服务: org.jboss.weld.bootstrap.WeldStartup.startContainer WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked

我已经在Tomcat中安装了Weld/CDI,并且工作正常,但在启动时,它说没有启用事务服务:

org.jboss.weld.bootstrap.WeldStartup.startContainer WELD-000101:
  Transactional services not available. Injection of @Inject 
  UserTransaction not available. Transactional observers will be 
  invoked synchronously.
My pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>TestWebSocket</artifactId>
    <version>1.0-SNAPSHOT</version>

    <packaging>war</packaging>

    <!-- Tell Maven what language version to use -->
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>

        <!-- https://mvnrepository.com/artifact/javax.enterprise/cdi-api -->
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <version>2.0</version>
        </dependency>

        <!-- Enables the annotations, etc needed -->
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.exterprise</groupId>
                    <artifactId>cdi-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Our jersey libs -->
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>2.25.1</version>
        </dependency>

        <!-- CDI to JAX-RS Binding -->
        <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.containers.glassfish/jersey-gf-cdi-ban-custom-hk2-binding -->
        <dependency>
            <groupId>org.glassfish.jersey.containers.glassfish</groupId>
            <artifactId>jersey-gf-cdi</artifactId>
            <version>2.14</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.jboss.weld.servlet/weld-servlet-core -->
        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet-core</artifactId>
            <version>3.0.0.Final</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.jboss.weld/weld-core-impl -->
        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core-impl</artifactId>
            <version>3.0.0.Final</version>
        </dependency>

    </dependencies>

</project>

4.0.0
groupId
测试网袋
1.0-快照
战争
1.8
1.8
javax.enterprise
CDIAPI
2
爪哇
JavaEEAPI
7
javax.exterprise
CDIAPI
org.glassfish.jersey.containers
jersey容器servlet核心
2.25.1
org.glassfish.jersey.containers.glassfish
泽西gf cdi
2.14
org.jboss.weld.servlet
焊芯
3.0.0.1决赛
org.jboss.weld
焊芯植入
3.0.0.1决赛
web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
        version="3.1">

    <servlet>
        <servlet-name>Example API</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>

        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>com.testpush</param-value>
        </init-param>

        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Example API</servlet-name>
        <url-pattern>/events/*</url-pattern>
    </servlet-mapping>

    <listener>
        <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
    </listener>

    <resource-env-ref>

        <resource-env-ref-name>BeanManager</resource-env-ref-name>

        <resource-env-ref-type>

            javax.enterprise.inject.spi.BeanManager

        </resource-env-ref-type>

    </resource-env-ref>
</web-app>

<?xml version="1.0" encoding="utf-8"?>
<Context>

    <Resource name="BeanManager"

            auth="Container"

            type="javax.enterprise.inject.spi.BeanManager"

            factory="org.jboss.weld.resources.ManagerObjectFactory"/>

</Context>

示例API
org.glassfish.jersey.servlet.ServletContainer
jersey.config.server.provider.packages
com.testpush
1.
示例API
/事件/*
org.jboss.weld.environment.servlet.Listener
豆管员
javax.enterprise.inject.spi.BeanManager
beans.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
        http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
    bean-discovery-mode="all">
</beans>

您需要从Weld SPI提供
事务服务的实现,然后通过
ServiceLoader
将其注册为
META-INF/services/org.jboss.Weld.bootstrap.api.Service


可以找到完整的详细信息

您能否提供一个指向实现它的github项目的链接?