无法解析符号 BeanPropertyRowMapper
Cannot resolve symbol BeanPropertyRowMapper
我有下面的代码
List<Tbl> list = temp.query("select * from tbl WHERE DDMM = " + ddmm.format(date), new BeanPropertyRowMapper<Tbl>(Tbl.class));
错误
error: cannot find symbol
List<Tbl> list = temp.query("select * from tbl WHERE DDMM = " + ddmm.format(date), new BeanPropertyRowMapper<Tbl>(Tbl.class));
symbol: class BeanPropertyRowMapper
BeanPropertyRowMapper
要求 spring-jdbc
JAR 出现在类路径中。为此,您需要编译程序并使用命令行标志在类路径中手动包含 spring-jdbc
JAR。有关详细信息,请参阅 Including jars in classpath on commandline (javac or apt). The spring-jdbc
JAR can be found at Maven Repository。问题是 JAR 可能需要更多的依赖项,这可能会很麻烦。
我建议将您的项目转换为 Maven 项目。有关创建 Maven 项目的更多信息,请参阅 Maven in 5 Minutes。 Mavenize 项目后,将以下内容添加到 pom.xml
,其中 ${spring.version}
是您决定使用的 Spring 版本:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
然后,在使用BeanPropertyRowMapper
的文件中,添加如下导入语句:
import org.springframework.jdbc.core.BeanPropertyRowMapper;
我有下面的代码
List<Tbl> list = temp.query("select * from tbl WHERE DDMM = " + ddmm.format(date), new BeanPropertyRowMapper<Tbl>(Tbl.class));
错误
error: cannot find symbol
List<Tbl> list = temp.query("select * from tbl WHERE DDMM = " + ddmm.format(date), new BeanPropertyRowMapper<Tbl>(Tbl.class));
symbol: class BeanPropertyRowMapper
BeanPropertyRowMapper
要求 spring-jdbc
JAR 出现在类路径中。为此,您需要编译程序并使用命令行标志在类路径中手动包含 spring-jdbc
JAR。有关详细信息,请参阅 Including jars in classpath on commandline (javac or apt). The spring-jdbc
JAR can be found at Maven Repository。问题是 JAR 可能需要更多的依赖项,这可能会很麻烦。
我建议将您的项目转换为 Maven 项目。有关创建 Maven 项目的更多信息,请参阅 Maven in 5 Minutes。 Mavenize 项目后,将以下内容添加到 pom.xml
,其中 ${spring.version}
是您决定使用的 Spring 版本:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
然后,在使用BeanPropertyRowMapper
的文件中,添加如下导入语句:
import org.springframework.jdbc.core.BeanPropertyRowMapper;