This question already has an answer here:
How to properly install and configure JSF libraries via Maven?
(1个答案)
3年前关闭。
我在Eclipse中有两个Web项目:Framework和webxxx
在我的框架中,我有一些
当我从
如果将
框架:
WEBXXX项目:
这两个项目都有:
Web xxx项目依赖项:
框架依赖性:
(1个答案)
3年前关闭。
我在Eclipse中有两个Web项目:Framework和webxxx
在我的框架中,我有一些
utils
功能,例如复制,下载,上传等。当我从
webxxx
调用下载方法时,得到了*java.lang.NoClassDefFoundError: javax/faces/context/FacesContext*.
如果将
GerenciarArquivo
类移至webxxx项目,则downloadFile方法可以正常工作。框架:
public abstract class GerenciarArquivo{
...
public static void downloadFile(String filePath) throws IOException{
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) context
.getExternalContext().getResponse();
WEBXXX项目:
GerenciarArquivo.downloadFile(abb.getPath());
这两个项目都有:
Web xxx项目依赖项:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.9</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>provided</scope>
</dependency>
框架依赖性:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.9.Final</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
最佳答案
添加此依赖性,可以解决我的问题
未找到类异常:javax.faces.context.facesContext。
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
10-01 18:17