java - 使用 Maven for openshift 构建时出错

标签 java maven openshift

这是我的 POM.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
    <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>myapp</groupId>
<artifactId>myapp</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>myapp</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.executable>${env.OPENSHIFT_WILDFLY_DIR}usr/lib/jvm/jdk1.8.0_05/bin/javac</maven.compiler.executable>
    <maven.compiler.fork>true</maven.compiler.fork>

    <spring.version>4.1.3.RELEASE</spring.version>
    <jstl.version>1.2</jstl.version>
</properties>

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.34</version>
    </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 'deployments' folder. -->
        <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
        <id>openshift</id>
        <build>
            <finalName>myapp</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.3</version>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                        <outputDirectory>deployments</outputDirectory>
                        <warName>ROOT</warName>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

当我使用 mvn 包构建时,我得到

------------------------------------------------------------------------
Building myapp 1.0
------------------------------------------------------------------------

--- maven-resources-plugin:2.5:resources (default-resources) @ myapp ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
Copying 1 resource

--- maven-compiler-plugin:2.3.2:compile (default-compile) @ myapp ---
Compiling 1 source file to D:\git\myapp\target\classes
-------------------------------------------------------------
COMPILATION ERROR : 
-------------------------------------------------------------
Failure executing javac,  but could not parse the error:
The system cannot find the path specified.

1 error
-------------------------------------------------------------
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 0.711s
Finished at: Wed Dec 31 13:15:42 IST 2014
Final Memory: 6M/15M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project myapp: Compilation failure
Failure executing javac,  but could not parse the error:
The system cannot find the path specified.
-> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

可能是什么问题?

最佳答案

我在我们的小组项目中遇到了同样的问题。特别是这一行正在破坏您的构建:

<maven.compiler.executable>${env.OPENSHIFT_WILDFLY_DIR}usr/lib/jvm/jdk1.8.0_05/bin/javac</maven.compiler.executable>

它指定javac编译java文件的路径。然而,上面的这一行指向一个固定路径(在所有计算机上并不相同)。删除它,您的本地构建就会通过。但是,我怀疑如果删除该行,可能会破坏 openshift 方面的某些内容。

关于java - 使用 Maven for openshift 构建时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27718040/

相关文章:

java - 如何直接在应用内浏览器(Chrome 自定义选项卡)中打开外部链接,而不提示选择浏览器

jsp - java.lang.ClassNotFoundException : org. apache.jsp.index_jsp

nginx - 将 openshift 路由从 http 更改为 https 时 x-forwarded-for header 丢失

postgresql - 如何重新启动我的 openshift postgres 墨盒?

node.js - 如何通过mongojs模块从nodejs查询mongodb? (服务器是openshift)

java - 从当前包中获取文件

Java 使用 String[] args 作为输入,如何检索其内容?

java - 更新依赖项中的版本时更新模块版本(多模块 maven )

java - Spring MVC Maven 项目中的 org.springframework.beans.factory.BeanCreationException

java - @NamedQuery : identification variable 'sysdate' is not defined in the FROM clause