执行构建时MojoExecutionException - Maven

时间:2015-05-19 14:54:26

标签: java maven liferay maven-3 liferay-6

以下是我在我的pom中构建maven项目时所包含的目标。

<?xml version="1.0"?> 

<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>com.mynewproject.portlet</groupId>
    <artifactId>abc-myfacts-portlet</artifactId>
    <packaging>war</packaging>
    <name>ABC MY FACTS Portlet</name>
    <version>2.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>com.liferay.maven.plugins</groupId>
                <artifactId>liferay-maven-plugin</artifactId>
                <version>${liferay.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>build-css</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
                    <appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
                    <appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
                    <appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
                    <liferayVersion>${liferay.version}</liferayVersion>
                    <pluginType>portlet</pluginType>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>




        </plugins>

    </build>
    <dependencies>
            <!-- Liferay dependency -->    
            <dependency>
                 <groupId>commons-lang</groupId>
                 <artifactId>commons-lang</artifactId>
                <version>2.6</version>                  
</dependency>

<dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>3.2.1</version>
    <optional>true</optional>
</dependency>

 <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.6.5</version>
        </dependency>
         <!--  <dependency> 
            <groupId>org.springframework</groupId>
            <artifactId>spring-instrument</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency> -->




        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>portal-service</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>util-bridges</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>util-taglib</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>util-java</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>

            <!-- Portlet/JSR dependency -->      
        <dependency>
            <groupId>javax.portlet</groupId>
            <artifactId>portlet-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>

            <!-- Servlet/JSP dependency -->      
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
            <scope>runtime</scope>          
        </dependency> 

        <!-- Spring dependency -->       
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc-portlet</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>    
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>       
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency> 
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>
        <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-agent</artifactId>
    <version>2.5.6</version>
</dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.6.12</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3</version>
        </dependency>

        <!-- Log4j configuration -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.4.2</version>
        </dependency> 

        <!-- Unit testing -->       
        <dependency>  
            <groupId>org.mockito</groupId>  
            <artifactId>mockito-all</artifactId>  
            <version>1.9.5</version>  
        </dependency>  
        <dependency>  
            <groupId>junit</groupId>  
            <artifactId>junit</artifactId>  
            <version>4.11</version>  
        </dependency>   

         <!-- Data Service dependency -->
        <dependency>
            <groupId>com.mynewproject.components</groupId>
            <artifactId>abc-mynewproject-service</artifactId>
            <version>2.0-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>com.mynewproject.components</groupId>
            <artifactId>emailcomponent</artifactId>
            <version>2.0-SNAPSHOT</version>
        </dependency>

    </dependencies>



<profiles>
<profile>
    <id>Liferay-v6.2-EE-(Tomcat-7)</id>
    <properties>
        <liferay.version>6.2.2</liferay.version>
        <liferay.maven.plugin.version>7.0.0-m2</liferay.maven.plugin.version>
        <liferay.auto.deploy.dir>..\Liferay Portal\liferay-portal-6.2.10.1-ee-ga1\deploy</liferay.auto.deploy.dir>
        <liferay.app.server.deploy.dir>..\Liferay Portal\liferay-portal-6.2.10.1-ee-ga1\tomcat-7.0.42\webapps</liferay.app.server.deploy.dir>
        <liferay.app.server.lib.global.dir>..\Liferay Portal\liferay-portal-6.2.10.1-ee-ga1\tomcat-7.0.42\lib\ext</liferay.app.server.lib.global.dir>
        <liferay.app.server.portal.dir>..\Liferay Portal\liferay-portal-6.2.10.1-ee-ga1\tomcat-7.0.42\webapps\ROOT</liferay.app.server.portal.dir>
    </properties>
    </profile>

</profiles>
</project>

但是当我执行构建时,我得到以下错误:

  

[错误]无法执行目标   com.liferay.maven.plugins:Liferay的,Maven的插件:6.2.1:内置CSS   (默认)在项目myNewProject上:null:MojoExecutionException:   NullPointerException - &gt; [帮助1]

     

org.apache.maven.lifecycle.LifecycleExecutionException:失败   执行目标   com.liferay.maven.plugins:Liferay的,Maven的插件:6.2.1:内置CSS   (默认)项目myNewProject:null           在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)           在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)           在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)           在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)           在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)           在org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)           在org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)           在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)

我的问题是:

在执行构建时,它是什么导致空指针异常?

1 个答案:

答案 0 :(得分:-1)

  1. 首先,如果pom.xml中提到了你的生活版本,你需要检查它。

  2. 此外,当您尝试使用旧版Maven构建Liferay项目时,可能会引发错误。使用命令

    检查您正在使用的Maven版本

    mvn -version

  3. 此外,您正在使用的JDK应在POM.xml中正确提及。 我发现khmarbaise的评论是正确的,因为该版本可能也存在冲突。希望这会有所帮助。