2016-04-08 36 views
0

我尝试使用开班。并尝试从eclipse与openshift插件帮助openshift tomcat 7部署动态Web项目。而当我尝试部署我有建设错误,我不好在maven,但像我明白这是因为maven没有看到我的web.xml,但我有我的web.xml中。项目没有一些奇特的api。这是我的WebContent/WEB-INF/web.xml文件:maven webxml属性的错误是必需的,但我有我的网站xml?

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
    id="WebApp_ID" version="3.0"> 
    <display-name>Test</display-name> 
    <welcome-file-list> 
     <welcome-file>index.html</welcome-file> 
     <welcome-file>index.htm</welcome-file> 
     <welcome-file>index.jsp</welcome-file> 
     <welcome-file>default.html</welcome-file> 
     <welcome-file>default.htm</welcome-file> 
     <welcome-file>default.jsp</welcome-file> 
    </welcome-file-list> 
</web-app> 

当我尝试构建它,我有:

[INFO] BUILD FAILURE 
[INFO] --------------------------------------------------------------------- 
[INFO] Total time: 3.525s 
[INFO] Finished at: Fri Apr 08 14:01:52 EDT 2016 
[INFO] Final Memory: 8M/111M 
[INFO] --------------------------------------------------------------------- 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project mywebtestproject: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) 

[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 
An error occurred executing 'gear postreceive' (exit code: 1) 
Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/5707e54c2d52712b110000cf/jbossews 

,这是我的pom.xml

<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/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>mywebtestproject</groupId> 
    <artifactId>mywebtestproject</artifactId> 
    <packaging>war</packaging> 
    <version>1.0</version> 
    <name>mywebtestproject</name> 
    <repositories> 
     <repository> 
      <id>eap</id> 
      <url>http://maven.repository.redhat.com/techpreview/all</url> 
      <releases> 
       <enabled>true</enabled> 
      </releases> 
      <snapshots> 
       <enabled>true</enabled> 
      </snapshots> 
     </repository> 
    </repositories> 
    <pluginRepositories> 
     <pluginRepository> 
      <id>eap</id> 
      <url>http://maven.repository.redhat.com/techpreview/all</url> 
      <releases> 
       <enabled>true</enabled> 
      </releases> 
      <snapshots> 
       <enabled>true</enabled> 
      </snapshots> 
     </pluginRepository> 
    </pluginRepositories> 
    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <maven.compiler.source>1.6</maven.compiler.source> 
     <maven.compiler.target>1.6</maven.compiler.target> 
    </properties> 
    <dependencies> 
     <dependency> 
      <groupId>org.postgresql</groupId> 
      <artifactId>postgresql</artifactId> 
      <version>9.2-1003-jdbc4</version> 
     </dependency> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.25</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>javax.servlet-api</artifactId> 
      <version>3.0.1</version> 
      <scope>provided</scope> 
     </dependency> 
    </dependencies> 
    <profiles> 
     <profile> 
      <!-- When built in OpenShift the 'openshift' profile will be used when 
       invoking mvn. --> 
      <!-- Use this profile for any OpenShift specific customization your app 
       will need. --> 
      <!-- By default that is to put the resulting archive into the 'webapps' 
       folder. --> 
      <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html --> 
      <id>openshift</id> 
      <build> 
       <finalName>mywebtestproject</finalName> 
       <plugins> 
        <plugin> 
         <artifactId>maven-war-plugin</artifactId> 
         <version>2.1.1</version> 
         <configuration> 
          <outputDirectory>webapps</outputDirectory> 
          <warName>ROOT</warName> 
         </configuration> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
    </profiles> 
</project> 
+1

1.该插件找不到web.xml。显示项目文件夹结构。 2.为什么选择版本maven-war-plugin 2.1.1,它是5岁的 – michaldo

回答

0

难道你尝试把这个放在你的pom.xml中?包括<webXml>标签。

 <build> 
      <finalName>mywebtestproject</finalName> 
      <plugins> 
       <plugin> 
        <artifactId>maven-war-plugin</artifactId> 
        <version>2.1.1</version> 
        <configuration> 
         <outputDirectory>webapps</outputDirectory> 
         <warName>ROOT</warName> 
         <webXml>src/main/webapp/WEB-INF/web.xml</webXml> 
        </configuration> 
      </plugin> 
     </plugins> 
    </build> 
+0

在配置中包含标签** **。 – ffSouza

+0

如果是这样,但不要使用反斜杠....并使用更高级的maven-war-plugin版本,请参阅https://maven.apache.org/plugins/maven-war-plugin/ – khmarbaise