Justin
Justin

Reputation: 886

JSF correct use of jsf-api dependency

Ok, I am a little confused on the differences between jsf-api implementations.

<dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-api</artifactId>
      <version>2.2.8</version>
    </dependency>

<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.1</version>
</dependency>

I am not sure what the differences are between these two. I thought they do the same thing and allow the javax.faces imports but now I have confused myself. Can anyone please explain these two differences? Thanks :)

Upvotes: 0

Views: 777

Answers (1)

LaurentG
LaurentG

Reputation: 11787

There was somes changes with the groupId of the Maven JSF-API dependency since the first version. For JSF 2.2 (current version as I'm writing this), you should use the following recommended dependency, if you are running in a container supporting JSF:

<dependency>
  <groupId>javax.faces</groupId>
  <artifactId>javax.faces-api</artifactId>
  <version>2.2</version>
  <scope>provided</scope>
</dependency>

If your container does not support JSF (like Tomcat), use the following dependency if you want to use Mojarra (the default JSF implementation):

<dependency>
  <groupId>org.glassfish</groupId>
  <artifactId>javax.faces</artifactId>
  <version>2.2.8</version>
</dependency>

Other recommmendation and information are available on the official page of JSF.

Upvotes: 2

Related Questions