首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

seam 属性配备与installed="false"的冲突

2012-10-28 
seam 属性配置与installedfalse的冲突问题在测试和运行环境使用不同的事务配置,默认不需要指定事务(使

seam 属性配置与installed="false"的冲突
问题

在测试和运行环境使用不同的事务配置,默认不需要指定事务(使用jta),测试时需要使用jpa 事务,这时就必须在components.xml中显示配置jpa事务,如果测试和运行时都使用同一components.xml,可以通过maven属性控制

transaction:entity-transaction组件的installed。

<transaction:entity-transaction entity-manager="#{entityManager}" installed="${entity-transaction.installed}"></transaction:entity-transaction>

?

在web-inf\components.xml中配置的组件即使installed="false",它里面的属性也会被使用。

如下配置指定了默认的seam事务(org.jboss.seam.transaction.Transaction类,不是。。EntityTransaction类),当创建Transaction类实例后会把entity-manager属性向实例中反射设置,这样会抛出Transaction类没有entityManager属性的异常。

<transaction:entity-transaction entity-manager="#{entityManager}" installed="false"></transaction:entity-transaction>

?

解决

生成两个不同环境的components.xml文件,一个中定义entity-transaction,一个中不定义,这样就不会把不可用组件的属性使用了。

<transaction:entity-transaction entity-manager="#{entityManager}" ></transaction:entity-transaction>

要解决如何指定使用哪个components.xml文件。

?

在src/main/下建立webapptest文件夹下面只建立WEB-INF/components.xml

?

<plugin>
??? ??? ??? ??? ??? ??? <groupId>org.apache.maven.plugins</groupId>
??? ??? ??? ??? ??? ??? <artifactId>maven-war-plugin</artifactId>
??? ??? ??? ??? ??? ??? <configuration>
??? ??? ??? ??? ??? ??? ??? <webResources>
??? ??? ??? ??? ??? ??? ??? ??? <resource>
??? ??? ??? ??? ??? ??? ??? ??? ??? <!-- this is relative to the pom.xml directory -->
??? ??? ??? ??? ??? ??? ??? ??? ??? <directory>src/main/webapp</directory>
??? ??? ??? ??? ??? ??? ??? ??? ??? <filtering>true</filtering>
??? ??? ??? ??? ??? ??? ??? ??? ??? <includes>
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <include>**/web.xml</include>
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <include>**/footer.xhtml</include>
??? ??? ??? ??? ??? ??? ??? ??? ??? </includes>
??? ??? ??????? ??? ??? ??? ??? ??? <excludes>
??? ??? ??????? ??? ??? ??? ??? ??? ??? <exclude>**/*.scc</exclude>
??? ??? ??????? ??? ??? ??? ??? ??? </excludes>
??? ??? ??? ??? ??? ??? ??? ??? </resource>
??? ??? ??? ??? ??? ??? ??? ??? <resource>
??? ??? ??? ??? ??? ??? ??? ??? ??? <!-- this is relative to the pom.xml directory -->
??? ??? ??? ??? ??? ??? ??? ??? ??? <directory>src/main/webapptest</directory>
??? ??? ??? ??? ??? ??? ??? ??? ??? <filtering>true</filtering>
??? ??? ??? ??? ??? ??? ??? ??? ??? <includes>
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <include>**/components.xml</include>
??? ??? ??? ??? ??? ??? ??? ??? ??? </includes>
??? ??? ??????? ??? ??? ??? ??? ??? <excludes>
??? ??? ??????? ??? ??? ??? ??? ??? ??? <exclude>**/*.scc</exclude>
??? ??? ??????? ??? ??? ??? ??? ??? </excludes>
??? ??? ??? ??? ??? ??? ??? ??? </resource>
??? ??? ??? ??? ??? ??? ??? </webResources>
??? ??? ??? ??? ??? ??? </configuration>
??? ??? ??? ??? ??? </plugin>

?

热点排行