这是我的POM.xml文件:
<project>
<properties>
<jdk.version>1.6</jdk.version>
<spring.version>3.2.2.RELEASE</spring.version>
<spring.batch.version>2.2.0.RELEASE</spring.batch.version>
<mysql.driver.version>5.1.25</mysql.driver.version>
<junit.version>4.11</junit.version>
</properties>
<dependencies>
<!-- Spring Core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Spring jdbc, for database -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Spring XML to/back object -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.driver.version}</version>
</dependency>
<!-- Spring Batch dependencies -->
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>${spring.batch.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-infrastructure</artifactId>
<version>${spring.batch.version}</version>
</dependency>
<!-- Spring Batch unit test -->
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
<version>${spring.batch.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>spring-batch</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
下面是我的java类:
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class App {
public static void main(String[] args) {
String[] springConfig =
{
"spring/batch/jobs/job-hello-world.xml"
};
ApplicationContext context =
new ClassPathXmlApplicationContext(springConfig);
JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
Job job = (Job) context.getBean("helloWorldJob");
try {
JobExecution execution = jobLauncher.run(job, new JobParameters());
System.out.println("Exit Status : " + execution.getStatus());
} catch (Exception e) {
e.printStackTrace();
}
}
}
我在App.java类的import语句中遇到错误,这是消息:
“导入org.springframework无法解析。”
我清楚地提到了POM.xml中的依赖关系,但是我的java类仍然不能从那里选择依赖关系。
您需要按照一些步骤进行正确的调试。
1)mvn clean dependency:tree
查看输出,以确切地了解所获得的内容并验证依赖项是否全部存在。
2)mvn clean compile
。这会失败吗?如果不是,那意味着您仅在Eclipse中得到错误?
您在评论中提到“并且我在上面同时运行了两个命令,但出现此错误”。做了mvn clean compile
工作?还是您也为此出错?如果它能正常工作,那只是一个IDE问题,我来看看这个m2eclipse
插件。更好的是,使用IntelliJ,因为免费版本比Eclipse具有更好的maven支持;-)
一些风格的东西…
人们在不需要时经常在pom文件中添加过多的依赖项。如果你在一对夫妇在mavenrepository.com链接看看你可以看到,spring- oxm
并spring-jdbc
都依赖于spring-core
这样你就需要添加一个明确(做示例)。mvn clean dependency:tree
会告诉您所有这些内容,但是这更加整洁。
spring-batch-test
应该是test
范围。
这是我的POM。xml文件: 下面是我的java类: 我得到一个错误的导入语句在我的App.java类,这是消息: “无法解析导入org.springframework。” 我清楚地提到了POM. xml中的依赖项,但是我的java类仍然不能从那里选择依赖项。
我试图在我的项目中使用Spring框架,但我有一个导入问题。我正在使用Gradle进行构建,前端使用React JS,后端使用Java。 奇怪的是,即使VS Code告诉我我的导入无法解析,我也可以将类用作RowMapper和JdbcTemboard(我可以使用这些类在我的数据库中读写)。 当我使用Gradle进行构建时(在命令提示符下是Gradle build,然后是Gradle bootrun
问题内容: 出于某种原因,在完成了Phonegap的非包含性说明(甚至没有提到设置ANT,或者没有遇到Ant和JDK的麻烦)之后,这根本不起作用: 它给出了5个错误,指出无法解析org.apache.cordova的事实。我完全确定此时该怎么办。请帮忙。这是在尝试使sdk正常工作并最终能够在eclipse中打开项目的3个小时之后。按照他们的文档中的步骤进行操作后,除非能弄清楚,否则我将浪费3个小时
问题内容: 我在用macOS 10.13.5编写的MacBookPro上安装了Eclipse [Version:Photon Release(4.8.0)]和JDK 10。 我得到错误: 导入java.awt无法解析 是包含在JDK 10?如果是,在哪里,如何使Eclipse可见?如果没有,如何添加java.awt? 问题答案: 是包含在JDK 10? 是的,包裹确实存在。Java10 API文档
问题内容: 我有一个问题,日食说它找不到javax.ejb.Schedule(或时间表),但与其他类(如javax.ejb.MessageDriven)没有问题。我正在处理一个我不太了解的大型应用程序。所以我的问题是如何解决这个问题?还是寻找方法? 问题答案: JBoos 4是兼容JEE5的服务器,因此JEE6功能不可用。
问题内容: 我正在尝试使用 Eclipse for Java EE 开发Web应用程序。 我需要使用 Tomcat 作为 服务器 。我已经下载了Tomcat并且它正在运行。但是我的程序无法编译。 我收到以下错误: 导入javax.servlet无法解析。 我需要做什么? 问题答案: 您需要将Servlet API添加到类路径中。在Tomcat 6.0中,它位于Tomcat 文件夹中的JAR 中。您