[ https://issues.apache.org/jira/browse/DELTASPIKE-1421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17295294#comment-17295294 ]
Mark Struberg commented on DELTASPIKE-1421: ------------------------------------------- A standard way with DeltaSpike is to use an {{@Exclude(exceptIfProjectStage(Production.class))}} on those classes. That will ProcessAnnotatedType.veto() those classes during bootstrap when running as unit test. You just need to set the ProjectStage to UnitTest for your tests. You should find this in the docs. > Cannot exclude ApplicationScoped with @Produces method > ------------------------------------------------------ > > Key: DELTASPIKE-1421 > URL: https://issues.apache.org/jira/browse/DELTASPIKE-1421 > Project: DeltaSpike > Issue Type: Bug > Security Level: public(Regular issues) > Components: CdiControl > Affects Versions: 1.9.4 > Reporter: Fabrizio Stellato > Priority: Major > > I have *ApplicationScoped* beans on the _main_ java folder which work as > resources class, therefore they contains methods with _Produces_ annotation . > I'm currently using cucumber + deltaspike dependencies, and when I run my > test I can see ALL dependencies are implicit injected. > As I don't want to do that, I decided to exclude those ApplicationScoped > classes from _beans.xml_ in this way: > {code:java} > <weld:exclude pattern="^(.*)ServiceProducer$" /> > <weld:exclude pattern="^(.*)LoggerProducer$" /> > {code} > When I start my cucumber test, I can see these classes are still scanned, > thus I receive ambiguos dependency because of my mock classes on _test_ > folder. > Is there any way to exclude above classes with success or, even better, to > explicitly add bean classes? > -- This message was sent by Atlassian Jira (v8.3.4#803005)