What is the difference between mappedName attributes and @Resource attribute lookup in EJB?

I am confused between two @Resource annotation @Resource .

The Java documentation says:
mapped name:. The product-specific name for which this resource should be mapped. The name of this resource, defined by a name element or default, is a name that is a local component of the application using the resource. (This is the name in the JNDI java namespace: comp / env.) Many application servers provide a way to map these local names to resource names known to the application server. This display name is often the global JNDI name, but can be any form of name.
lookup:. The name of the resource that this link points to. It can reference any compatible resource using global JNDI names.

My question is how to choose a matching name and search , based on what criteria?

+6
source share
1 answer

As he says, mappedName is product specific and is not supported by many application servers. So for now, you should use lookup , as it should be portable and cross-platform. You specify the global JNDI of this resource.

+8
source

Source: https://habr.com/ru/post/973089/


All Articles