我为项目配置了SVN-Jenkins-Maven-Tomcat。小项目的每件事情都很好。但是当我尝试构建包含大量jar和包的实际项目时...它显示错误..找不到xxx包。我已经手动将依赖jar添加到本地maven存储库。
的pom.xml:
<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>optaplanner</groupId>
<artifactId>optaplanner</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>annotation.code</groupId>
<artifactId>annotations</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>antlr-runtime.code</groupId>
<artifactId>antlr-runtime</artifactId>
<version>3.5</version>
</dependency>
.....
.....
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
错误:
/C:/Users/ANIRBAND/.jenkins/jobs/Test/workspace/src/main/java/org/optaplanner/examples/common/swingui/SolutionPanel.java:[25,48] 包org.optaplanner.core.api.domain.solution不存在 /C:/Users/ANIRBAND/.jenkins/jobs/Test/workspace/src/main/java/org/optaplanner/examples/common/swingui/SolutionPanel.java:[72,29] 找不到标志 /C:/Users/ANIRBAND/.jenkins/jobs/Test/workspace/src/main/java/org/optaplanner/examples/common/swingui/ConstraintMatchesDialog.java:[45,17] 包org.slf4j不存在
你能帮我解决一下吗?
答案 0 :(得分:1)
鉴于错误消息,我认为您没有将slf4j作为依赖项添加到您的项目中?
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
</dependency>
您能否发布完整的pom.xml和错误消息?
答案 1 :(得分:0)
首先要在项目中添加SLF4j
,为此添加SLF4j API
:
<properties>
<slf4jVersion>1.7.12</slf4jVersion>
</properties>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4jVersion}</version>
</dependency>
接下来选择一个绑定库;来自以下之一:
1)。绑定 NOP ,默默地丢弃所有日志记录。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>${slf4jVersion}</version>
</dependency>
2)。绑定 System.out
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4jVersion}</version>
</dependency>
3)。绑定 log4j 版本1.2.x.还需要在类路径上放置log4j.jar
。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4jVersion}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>runtime</scope>
</dependency>
4)。通过slf4j绑定 commons logging 。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4jVersion}</version>
<scope>runtime</scope>
</dependency>