来自 关于计算机 2019-11-03 04:55 的文章
当前位置: 六合联盟网 > 关于计算机 > 正文

Linux下Open JDK导致的Maven Build出错

今日在新的Linux服务器元帅项目check out出来之后,重新build,就涌出了上面包车型地铁标题:

转发注脚:请必需保留原著链接

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1:war (default-war) on project rendezvous: Error assembling WAR: Failed to         read filesystem attributes for: /opt/dev1/test/target/test/WEB-INF/web.xml: Failed to retrieve numeric file attributes using: '/bin/sh -c l        s -1nlad /opt/dev1/test/target/test/WEB-INF/web.xml': Error while executing process. Cannot run program "/bin/sh": java.io.IOException: err        or=12, Cannot allocate memory -> [Help 1]

初藳连接: 

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1:war (default-war) on proj        ect rendezvous: Error assembling WAR: Failed to read filesystem attributes for: /opt/dev1/test/target/dev1/WEB-INF/web.xml

 

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)

概述

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)

1.Spring Boot集合工程打包war安插汤姆cat

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)

2.Spring Boot打包Jar,通过Java -jar直接运营.

        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 

3.提供整机pom.xml测量检验项目 至github

谷歌(Google卡塔尔了生龙活虎圈未有找到有效的新闻,最终请教了Maven的牛人,猜想是JDK引起的。因为本人设置的是Open JDK。于是抱着试试看的神态,卸载了Open JDK,然后下载安装了Sun JDK。再运转mvn package -Dmaven.test.skip=true, 真的面世了BUILD SUCCESS。 

4.品种前段时间了集成了 Spring Boot + Spring data jpa +Redis集群+dubbo+freemarker 持续更新...

忽地想起在此以前好像因为Open JDK现身过任何主题材料,这时候就换了Sun的。所以不推荐大家使用OPEN-JDK

 

图片 1

解决难点

1.xxxx中一向不主清单属性

2.解决没有web.xml而报错

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project provider: Error assembling WAR: webxml attribute is required(or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

 

版本

1.JDK 1.8

2.Spring Boot 1.5.8

3.apache-tomcat-8.5.23

 

一.

打包war部署tomcat

1.改写App类 继承SpringBootServletInitializer

2.重写configure方法,返回builder.sources(YouApp.class);

3.添加pom.xml ,如下图

4.修改<packaging>war</packaging>

5.package命令打包

6.可参谋 github--> releases--> v0.2中blog-main-service 它是一个可打包jar且通过java -jar运营的欧洲经济共同体项目布署

地址:

public class ManagerApplication extends SpringBootServletInitializer{

  //  for tomcat
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { 
       return builder.sources(ManagerApplication.class);
   }

    public static void main(String[] args) throws InterruptedException {
        SpringApplication application = new SpringApplication(ManagerApplication.class);
        //application.setBannerMode(Banner.Mode.OFF);
         application.run(args);
    }


}

  

   <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
     </dependency>

   <!--用于解决没有web.xml报错-->

    <plugin>
            <artifactId>maven-war-plugin</artifactId>
             <version>3.0.0</version>
    </plugin>

 

二.

打包Jar实行运转

1.行业内部的Application,不要继续SpringBootServletInitializer

2.修改pom,如图

3.package命令打包

4.可参照 github--> releases--> v0.2 中blog-main-web ,它是二个可打包war可安排tomcat中的完整配置

地址:

     <!--打包成jar-->
        <!--https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html-->
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

 

本文由六合联盟网发布于关于计算机,转载请注明出处:Linux下Open JDK导致的Maven Build出错

关键词: