关键词:
我有一个带有war和ear模块的SpringBoot项目,我使用maven(一个主要用于Java项目的自动化工具)和IntelliJ IDEAThis是我的war项目的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>
<parent>
<groupId>com.bendiciones</groupId>
<artifactId>bendiciones-parent</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>bendiciones-war</artifactId>
<name>bendiciones war</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.bendicionesbendiciones</groupId>
<artifactId>bendiciones</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>bendiciones</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.bendiciones.Application</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<scm>
<tag>bendiciones-parent-4.0.0-SNAPSHOT</tag>
</scm>
</project>
但是当我建立这个类时,我遇到了这个错误。
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.5.RELEASE:repackage (repackage) on project bendiciones-war: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.1.5.RELEASE:repackage failed: Unable to find main class -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.5.RELEASE:repackage (repackage) on project bendiciones-war: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.1.5.RELEASE:repackage failed: Unable to find main class
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
即使这个类存在于项目中
添加你的main(starterApplication)类。清单中的 "Main-Class "实际上是由 "layout "属性控制的。Spring Boot插件.
<build>
<plugins>
...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.your.starter.Application</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
而且你需要检查 META-INF/MANIFEST.MF
.
Main-Class: org.springframework.boot.loader.WarLauncher
Start-Class: com.your.starter.Application
example.war
|
+-META-INF
| +-MANIFEST.MF
+-org
| +-springframework
| +-boot
| +-loader
| +-<spring boot loader classes>
+-WEB-INF
+-classes
| +-com
| +-mycompany
| +-project
| +-YourClasses.class
+-lib
| +-dependency1.jar
| +-dependency2.jar
+-lib-provided
+-servlet-api.jar
+-dependency3.jar
或者使用父子关系构建。
<build>
<pluginManagement>
<plugins>
...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</pluginManagement>
</build>
您正在用WAR打包您的应用程序,这表明您的应用程序是Web应用程序。因此,请在 pom.xml 中检查或添加以下重要的 Spring Boot 依赖关系。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
解决idea无法识别springboot项目(代码片段)
本文将来解决使用SpringInnitializer创建SpringBoot项目后,IDEA无法正常识别SpringBoot项目的问题.引言使用SpringInnitializer创建SpringBoot项目解决方案引言笔者使用的IDEA版本为2020.2.4,在使用SpringInnitializer创建SpringBoot项目后,SpringBoot项目无法... 查看详情
Maven与warpath的瘦身战争
】Maven与warpath的瘦身战争【英文标题】:Mavenskinnywarwithwarpath【发布时间】:2012-07-1106:46:11【问题描述】:我有一个项目,其中3个战争模块被打包在一个耳模块中。我的问题是每个库jar都包含在每个war-modules以及ear-module中,这使... 查看详情
无法使用具有 Z/OS 依赖关系的 maven 构建战争
】无法使用具有Z/OS依赖关系的maven构建战争【英文标题】:UnabletobuildwarusingmavenwithZ/OSdependency【发布时间】:2021-03-1821:26:04【问题描述】:我正在尝试使用以下依赖项构建一场战争<dependency><groupId>com.ibm</groupId><arti... 查看详情
无法在 Maven 部署 github 操作上重命名战争或 jar 文件
】无法在Maven部署github操作上重命名战争或jar文件【英文标题】:Cannotrenameawarorjarfileonamavendeploygithubactions【发布时间】:2021-10-2717:41:06【问题描述】:当我尝试使用github操作部署war或jar文件时,我无法将war/jar文件重命名为我想... 查看详情
springboot项目的创建与启动(代码片段)
...ff0c;不贰过。小知识,大智慧。💞当前专栏:SpringBoot框架从入门到精通✨特色专栏:国学周更-心性养成之路🥭本文内容:SpringBoot项目的创建与启动文章目录SpringBoot是什么SpringBoot的特点1.独立运行的Spring... 查看详情
springboot与thymeleaf
SpringBoot是微服务框架,可以快速的开发一个web项目,编译工具使用idea,可以很好的将maven与SpringBoot整合,页面交互使用thymeleaf,Spring官方推荐使用 在使用idea创建项目时发生问题,maven总是报错,换了一个maven本地仓库就可以了,原来是... 查看详情
在 Maven 中,如何在版本中命名战争文件与在快照构建中不同
】在Maven中,如何在版本中命名战争文件与在快照构建中不同【英文标题】:Inmaven,howtonamewarfiledifferentinreleasethaninsnapshotbuild【发布时间】:2014-08-2517:00:44【问题描述】:我正在使用maven-war插件。我还查看了maven-versions插件。在这... 查看详情
如何使用 maven 中的 tomcat 插件部署多个战争?
...点?有什么建议吗?【问题讨论】:【参考方案1】:我无法对此 查看详情
使用 spring boot 和 spring-boot-maven-plugin 生成战争时排除 application.properties
】使用springboot和spring-boot-maven-plugin生成战争时排除application.properties【英文标题】:Excludeapplication.propertieswhengeneratingwarusingspringbootandspring-boot-maven-plugin【发布时间】:2014-12-3120:51:54【问题描述】:我正在使用SpringBoot开发一个Web... 查看详情
springboot专题1----springboot与mybatis的完美融合
springboot大家都知道了,搭建一个spring框架只需要秒秒钟。下面给大家介绍一下springboot与mybatis的完美融合: 首先:创建一个名为springboot-mybatis的maven项目,记住:一定要maven哦,不懂maven的可以... 查看详情
使用 maven-release 后无法在竹子中部署 springboot jar
】使用maven-release后无法在竹子中部署springbootjar【英文标题】:Unabletodeployspringbootjarinbambooafterusingmaven-release【发布时间】:2018-01-2901:27:54【问题描述】:我正在使用BambooCICD管道使用maven版本构建和部署SpringBootjar。构建工作正常... 查看详情
springboot创建maven多模块项目
SpringBoot创建maven多模块项目项目结构 该项目名称为springboot-maven-multi,由springboot-maven-multi、user-dao、user-domain、user-service、user-web个模块组成,其中springboot-maven-multi模块是其他模块的父模块。 第一步:新建项目springboo... 查看详情
如何在使用 maven 构建的战争中包含系统依赖项
...:08:24【问题描述】:我在互联网上搜索了很长时间,但我无法弄清楚如何配置maven-war插件或类似的东西,以便将系统依赖项包含在内置战争中(WEB-INF/lib文件夹)在jar-build的情况下,我使用maven依赖插件:< 查看详情
在 Grails 3 中部署战争后无法创建文件流
】在Grails3中部署战争后无法创建文件流【英文标题】:FilestreamcouldnotbecreatedafterdeployingwarinGrails3【发布时间】:2021-12-2209:33:02【问题描述】:我的代码最后进入else块,并在战争模式下(部署到tomcat)记录“找不到文件”,但在... 查看详情
从 Spring Boot 项目部署战争
】从SpringBoot项目部署战争【英文标题】:deployingwarfromspringbootproject【发布时间】:2018-07-0513:52:55【问题描述】:我正在尝试基于spring-boot项目创建可部署的WAR,但是当我运行mvncleaninstall时出现以下异常嵌套异常是java.lang.IllegalArgu... 查看详情
springboot使用maven创建springboot项目
有两种方式可以创建 1是使用spring-boot-start-parent,2是使用spring-boot-dependencies(即父项目dependencyManagement)(同理springcloud 项目也可以使用两种方式创建,推荐使用dependencyManagement,后续笔记中补充)1.使用spring-boot-start-parent... 查看详情
SpringBoot + Maven 连接并创建数据库模式
】SpringBoot+Maven连接并创建数据库模式【英文标题】:SpringBoot+Mavenconnectsandcreatedatabaseschema【发布时间】:2018-12-1600:11:24【问题描述】:反正创建一个springboot应用程序,第一次运行时,连接mysql,如果不存在就创建数据库模式?我... 查看详情
springboot项目的创建:手动创建一个maven工程,然后引入springboot所需的dependency来完成(不需联网,但复杂)(代码片段)
SpringBoot项目的创建1.配置Maven环境。2.创建一个新的maven项目3.创建出来的目录结构4继承springboot父项目5.添加SpringBootMaven插件6.添加spring和web模块的依赖7.创建入口类8.添加代码测试1.配置Maven环境。在以maven方式创建SpringBoot项目之... 查看详情