I have the following @ApplicationScoped bean:
@ApplicationScoped
public class ServiceProducer {
private static final Logger logger = LoggerFactory.getLogger(ServiceProducer.class);
@Default
@Produces
@PersistenceContext(unitName = "nemo")
private EntityManager nemoEntityManager;
private CacheManager cacheManager;
@PostConstruct
void init() {
try {
cacheManager = Caching.getCachingProvider().getCacheManager(
Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("/ehcache.xml")).toURI(),
Thread.currentThread().getContextClassLoader());
} catch (URISyntaxException e) {
logger.error(e.getMessage());
}
}
@Produces
public CacheManager produceCacheManager() {
return cacheManager;
}
The above class is contained in a common / shared module of my web applications. This is good for production, however I need an alternative for integration test, which are done with Cucumber with wildspike integration.
By configuring beans.xml, unfortunately I cannot disable the bean above, I tried with configuring beans.xml in this way:
<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">
<scan>
<exclude name="it.myapp.ecommerce.commons.resource.ServiceProducer"></exclude>
</scan>
however nothing changes. Is it due because the class belongs from a dependency ?