Maven没有编译类,war文件中没有类文件 [英] Maven not compiling class and there is no class files in war file
本文介绍了Maven没有编译类,war文件中没有类文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将我的项目转换为maven。
我在war文件中看到没有可用的类文件。
iam converting my project to maven. I see in war file there is no class file available.
下面是pom.xml和项目结构。
Below is the pom.xml and project structure.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>RetailProducts</groupId>
<artifactId>RetailProducts</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>RetailProducts</name>
<dependencies>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
<!-- Tomcat 6 need this -->
<dependency>
<groupId>com.sun.el</groupId>
<artifactId>el-ri</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<build>
<finalName>JavaServerFaces</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<!-- <configuration> section added to pick up the WEB-INF/web.xml inside WebContent -->
<configuration>
<webResources>
<resource>
<directory>WebContent</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
项目结构
推荐答案
从我的观点来看,你的项目结构并不像maven所期望的那样。
From my point of view your project structure isn't as maven expects.
为了解决你的问题执行以下操作:
- 首先将您的包 retail.web.mbean 重命名为 main.java.retail.web.mbean (在您的包仍将命名为 retail.web.mbean 的过程之后),这将创建maven所需的文件夹结构。
- 右键单击项目,Maven>更新项目配置。
- First rename your package retail.web.mbean to main.java.retail.web.mbean (after the process your package will be still named retail.web.mbean), this will create the folder structure necessary for maven.
- Right click on the project, Maven > Update Project Configuration.
完成此过程后将具有与启动项目之前相同的结构,但maven将知道在哪里可以找到源代码。
After this process you will have the same structure you had before starting the project but maven will know where to find the source code.
此外,您可以创建资源文件夹并使用以下结构:
Additionally, you can create a resource folder and test folders with the following structure:
Project
src
main
java
resources
test
java
resources
这将是标准的maven项目结构。
This would be the standard maven project structure.
这篇关于Maven没有编译类,war文件中没有类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文