我用汗布创建了一个休息网络服务。我喜欢在我的项目中添加swagger来为其余界面创建文档。作为一个例子,我用swagger下载了一个休息项目。这是一个maven项目。
I installed maven on ubuntu & installed maven plugin into eclipse,
After a Maven clean, maven install & maven build on the project.
i get a few errors in console:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
In stackoverflow i see that someone has added manually this jar file?
Is it not a job for maven, because the dependency is in the pom?
--------------------------------------
...
2013-12-25 20:32:55.209:INFO:oejs.Server:jetty-8.1.11.v20130520
2013-12-25 20:32:56.168:WARN:oejw.WebAppContext:Failed startup of context o.m.j.p.JettyWebAppContext{/api,file:/home/scorpio/Downloads/swagger-core-swagger-project_2.9.1-1.3.0-RC1/samples/java-jaxrs/target/swagger-java-sample-app_2.9.1-1.3.0-RC1/},file:/home/scorpio/Downloads/swagger-core-swagger-project_2.9.1-1.3.0-RC1/samples/java-jaxrs/target/swagger-java-sample-app_2.9.1-1.3.0-RC1/
java.util.zip.ZipException: invalid entry size (expected 6164 but got 4968 bytes)
at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:386)
at java.util.zip.ZipInputStream.read(ZipInputStream.java:156)
at java.util.jar.JarInputStream.read(JarInputStream.java:195)
at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:100)
at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:78)
at java.util.jar.JarInputStream.getNextEntry(JarInputStream.java:130)
at java.util.jar.JarInputStream.getNextJarEntry(JarInputStream.java:167)
at org.eclipse.jetty.webapp.JarScanner.matched(JarScanner.java:162)
at org.eclipse.jetty.util.PatternMatcher.matchPatterns(PatternMatcher.java:100)
at org.eclipse.jetty.util.PatternMatcher.match(PatternMatcher.java:82)
at org.eclipse.jetty.webapp.JarScanner.scan(JarScanner.java:84)
.....
INFO] Started Jetty Server
[INFO]
[INFO] --- maven-failsafe-plugin:2.6:integration-test (default) @ swagger-java-sample-app_2.9.1 ---
[INFO] No tests to run.
[INFO]
[INFO] --- jetty-maven-plugin:8.1.11.v20130520:stop (stop-jetty) @ swagger-java-sample-app_2.9.1 ---
[INFO]
[INFO] --- maven-source-plugin:2.1.2:jar-no-fork (attach-sources) @ swagger-java-sample-app_2.9.1 ---
[INFO]
[INFO] --- maven-javadoc-plugin:2.7:jar (attach-javadocs) @ swagger-java-sample-app_2.9.1 ---
2013-12-25 20:32:56.778:INFO:oejsh.ContextHandler:stopped o.m.j.p.JettyWebAppContext{/api,file:/home/scorpio/Downloads/swagger-core-swagger-project_2.9.1-1.3.0-RC1/samples
....
I get also this errors in Problems tab:
'/home/scorpio/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.1.5/jackson-databind-2.1.5.jar' in project 'swagger-java-sample-app_2.9.1' cannot be read or is not a valid ZIP file swagger-java-sample-app_2.9.1 Build path Build Path Problem
maven-dependency-plugin (goals "copy-dependencies", "unpack") is not supported by m2e. pom.xml /swagger-java-sample-app_2.9.1 line 2 Maven Project Build Lifecycle Mapping Problem
Plugin execution not covered by lifecycle configuration: net.alchim31.maven:scala-maven-plugin:3.1.0:add-source (execution: default, phase: initialize) pom.xml /swagger-java-sample-app_2.9.1 line 2 Maven Project Build Lifecycle Mapping Problem
Plugin execution not covered by lifecycle configuration: net.alchim31.maven:scala-maven-plugin:3.1.0:testCompile (execution: default, phase: test-compile) pom.xml /swagger-java-sample-app_2.9.1 line 2 Maven Project Build Lifecycle Mapping Problem
-------
pom file:
<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">
<parent>
<groupId>com.wordnik</groupId>
<artifactId>swagger-project_2.9.1</artifactId>
<version>1.3.0-RC1</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>swagger-java-sample-app_2.9.1</artifactId>
<packaging>war</packaging>
<name>swagger-java-jaxrs-app</name>
<version>1.3.0-RC1</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-version}</version>
<configuration>
<webAppConfig>
<contextPath>/api</contextPath>
</webAppConfig>
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
<webDefaultXml>${project.basedir}/conf/jetty/webdefault.xml</webDefaultXml>
<stopPort>8079</stopPort>
<stopKey>stopit</stopKey>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8002</port>
<maxIdleTime>60000</maxIdleTime>
<confidentialPort>8443</confidentialPort>
</connector>
</connectors>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jaxrs_2.9.1</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.9.1</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
</dependencies>
</project>
Could someone give some extra info so that i can go on?
Thx
答案 0 :(得分:1)
根据您的日志存在多个问题
2013-12-25 20:32:56.168:WARN:oejw.WebAppContext:Failed startup of context o.m.j.p.JettyWebAppContext{/api,file:/home/scorpio/Downloads/swagger-core-swagger-project_2.9.1-1.3.0-RC1/samples/java-jaxrs/target/swagger-java-sample-app_2.9.1-1.3.0-RC1/},file:/home/scorpio/Downloads/swagger-core-swagger-project_2.9.1-1.3.0-RC1/samples/java-jaxrs/target/swagger-java-sample-app_2.9.1-1.3.0-RC1/
java.util.zip.ZipException: invalid entry size (expected 6164 but got 4968 bytes)
这只是意味着ZIP文件无效/不正确。要么它没有正确创建,要么在下载过程中发生中断。我建议删除该文件并重新创建/重新加载
'/home/scorpio/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.1.5/jackson-databind-2.1.5.jar' in project 'swagger-java-sample-app_2.9.1' cannot be read or is not a valid ZIP file swagger-java-sample-app_2.9.1 Build path Build Path Problem
删除此文件并重新获取
maven-dependency-plugin (goals "copy-dependencies", "unpack") is not supported by m2e. pom.xml /swagger-java-sample-app_2.9.1 line 2 Maven Project Build Lifecycle Mapping Problem
Plugin execution not covered by lifecycle configuration: net.alchim31.maven:scala-maven-plugin:3.1.0:add-source (execution: default, phase: initialize) pom.xml /swagger-java-sample-app_2.9.1 line 2 Maven Project Build Lifecycle Mapping Problem
Plugin execution not covered by lifecycle configuration: net.alchim31.maven:scala-maven-plugin:3.1.0:testCompile (execution: default, phase: test-compile) pom.xml /swagger-java-sample-app_2.9.1 line 2 Maven Project Build Lifecycle Mapping Problem
所有这些错误都指向一件事,m2e eclipse插件的限制。 m2e插件没有涵盖某些插件目标。除了确保每次构建都能正确地进行战争之外,你可以做些什么。