jetty-maven插件启动失败解决方法,java.util.zip.ZipException: error in opening zip file

本文记录了在Windows环境下使用Jetty插件启动项目时遇到的问题及解决方案。主要错误为ZipException,通过排查发现是由第三方库的POM文件缺失引起。

纯手打,转载请附上本文网址!!!

最近调一个项目,在Mac上一点问题没有,但是在Windows里就会报错始终启动不了(推荐使用maven的tomcat插件而不是jetty插件

jetty日志如下:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building taotao-manager-web 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> jetty-maven-plugin:9.4.5.v20170502:run (default-cli) > test-compile @ taotao-manager-web >>>
[WARNING] The POM for com.github.miemiedev:mybatis-paginator:jar:1.2.15 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ taotao-manager-web ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ taotao-manager-web ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ taotao-manager-web ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory F:\taotao\taotao-manager-web\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ taotao-manager-web ---
[INFO] No sources to compile
[INFO] 
[INFO] <<< jetty-maven-plugin:9.4.5.v20170502:run (default-cli) < test-compile @ taotao-manager-web <<<
[INFO] 
[INFO] --- jetty-maven-plugin:9.4.5.v20170502:run (default-cli) @ taotao-manager-web ---
[INFO] Logging initialized @4889ms to org.eclipse.jetty.util.log.Slf4jLog
[INFO] Configuring Jetty for project: taotao-manager-web
[INFO] webAppSourceDirectory not set. Trying src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = F:\taotao\taotao-manager-web\target\classes
[INFO] Context path = /
[INFO] Tmp directory = F:\taotao\taotao-manager-web\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] web.xml file = file:///F:/taotao/taotao-manager-web/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = F:\taotao\taotao-manager-web\src\main\webapp
[INFO] jetty-9.4.5.v20170502
[WARNING] Failed startup of context o.e.j.m.p.JettyWebAppContext@9d200de{/,file:///F:/taotao/taotao-manager-web/src/main/webapp/,UNAVAILABLE}{file:///F:/taotao/taotao-manager-web/src/main/webapp/}
java.util.zip.ZipException: error in opening zip file
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:219)
	at java.util.zip.ZipFile.<init>(ZipFile.java:149)
	at java.util.jar.JarFile.<init>(JarFile.java:166)
	at java.util.jar.JarFile.<init>(JarFile.java:103)
	at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
	at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
	at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:109)
	at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
	at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
	at org.eclipse.jetty.webapp.MetaInfConfiguration.getTlds(MetaInfConfiguration.java:439)
	at org.eclipse.jetty.webapp.MetaInfConfiguration.scanForTlds(MetaInfConfiguration.java:356)
	at org.eclipse.jetty.webapp.MetaInfConfiguration.scanJars(MetaInfConfiguration.java:173)
	at org.eclipse.jetty.webapp.MetaInfConfiguration.preConfigure(MetaInfConfiguration.java:107)
	at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:506)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:544)
	at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:432)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
	at org.eclipse.jetty.server.Server.start(Server.java:452)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
	at org.eclipse.jetty.server.Server.doStart(Server.java:419)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:460)
	at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:328)
	at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:170)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
	at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
[INFO] Started ServerConnector@3b36e000{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started @5819ms
[INFO] Started Jetty Server
注意这一行

[WARNING] The POM for com.github.miemiedev:mybatis-paginator:jar:1.2.15 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
原来是这个jar包的pom文件找不到,换一个版本就行了


经验总结如下:

不要忽略日志里面的warning,说不定有时候问题就出在这里

<think>嗯,用户遇到了Maven项目中Jetty插件无法解析的问题,具体是org.mortbay.jetty:maven-jetty-plugin:9.4.54.v20240208无法解析。首先,我需要回忆之前处理类似问题的经验,并结合提供的引用资料来找到解决方案。 首先,检查用户提供的引用。引用[4]提到Jetty插件的正确配置应该是org.eclipse.jetty组,而不是org.mortbay.jetty。因为Jetty项目已经从Mortbay转移到Eclipse基金会,所以组ID可能发生了变化。用户可能还在使用旧的组ID,导致Maven无法找到对应的插件。 然后,查看用户提到的版本9.4.54.v20240208是否真实存在。可能需要访问Maven中央仓库确认该版本是否存在。如果存在,但用户仍然遇到问题,可能是由于网络问题或仓库配置错误。但更可能的情况是组ID错误,导致无法解析。 接下来,考虑解决方案。根据引用[4],正确的配置应该使用org.eclipse.jetty作为groupId,artifactId是jetty-maven-plugin,并指定正确的版本号。用户当前的配置可能使用了旧的组ID,需要修改pom.xml中的插件配置。 此外,用户可能需要检查Maven的settings.xml文件,确保仓库配置正确,尤其是如果使用了私有仓库或镜像,可能存在配置问题。同时,清理Maven本地仓库的缓存也是一个有效步骤,可以排除损坏的依赖项。 另外,引用[3]中提到配置JDK版本,有时候插件版本与JDK不兼容也会导致问题。虽然Jetty插件的问题更可能与组ID有关,但检查JDK版本是否匹配也是一个值得考虑的步骤。 总结下来,主要步骤应该是:1. 更正pom.xml中的插件组ID和版本;2. 确认版本可用性;3. 检查仓库配置;4. 清理缓存;5. 检查JDK兼容性。</think>针对Maven项目中Jetty插件解析失败的问题,以下是分步解决方案: ### 问题分析 报错`unresolved jetty-maven-plugin 9.4.54.v20240208`通常由以下原因导致: 1. **插件坐标错误**:Jetty官方已迁移到`org.eclipse.jetty`组,而非旧版`org.mortbay.jetty`[^4] 2. **版本号不存在**:特定版本在Maven仓库中不可用 3. **Maven仓库配置问题**:本地仓库缓存损坏或远程仓库未同步 ### 解决方案 #### 1. 修正插件坐标(关键步骤) 在`pom.xml`中修改插件配置为: ```xml <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.4.54.v20240208</version> <!-- 配置项根据需求添加 --> </plugin> ``` 注意: - 确认使用`org.eclipse.jetty`而非`org.mortbay.jetty` - 验证版本号在[Maven中央仓库](https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-maven-plugin)是否存在 #### 2. 清理Maven缓存 执行命令清除本地仓库缓存: ```bash mvn dependency:purge-local-repository -DactTransitively=false ``` #### 3. 添加JDK版本配置(可选) 在`pom.xml`中添加JDK兼容性配置(参考引用[3]): ```xml <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> ``` #### 4. 验证仓库配置 检查`settings.xml`文件: ```xml <mirrors> <mirror> <id>aliyunmaven</id> <url>https://maven.aliyun.com/repository/public</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> ``` ### 验证步骤 1. 执行`mvn clean install` 2. 运行`mvn jetty:run` ### 典型错误对照表 | 错误现象 | 解决方案 | |---------|----------| | `Could not find artifact...` | 检查坐标拼写和版本号 | | `Plugin execution not covered` | 在IDEA中更新Maven配置 | | `Unsupported class file major version` | 调整JDK版本配置[^3] |
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值