错误:访问限制:类型“ DataSource”不是API(对所需库..\rt.jar的限制) [英] Error: Access restriction: The type 'DataSource' is not API (restriction on required library ..\rt.jar)

查看:91
本文介绍了错误:访问限制:类型“ DataSource”不是API(对所需库..\rt.jar的限制)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解如何使用Spring JDBC框架。

I'm trying to understand how to work with Spring JDBC framework.

我在 http://www.tutorialspoint.com/spring/spring_jdbc_example.htm 并尝试在我自己的项目中实现。

I've found example on http://www.tutorialspoint.com/spring/spring_jdbc_example.htm and trying to implement in my own project.

这是我的示例

package test;

import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;

public class TestJDBCTemplate {
       private DataSource dataSource;
       private JdbcTemplate jdbcTemplateObject;

       public void setDataSource(DataSource dataSource) {
          this.dataSource = dataSource;
          this.jdbcTemplateObject = new JdbcTemplate(dataSource);
       }

}

但是我遇到了

import javax.sql.DataSource

访问限制:类型'DataSource'不是API(对必需的库'C:\Program Files(x86)\Java\jre1.8.0_31\lib\rt的限制。 jar')

Access restriction: The type 'DataSource' is not API (restriction on required library 'C:\Program Files (x86)\Java\jre1.8.0_31\lib\rt.jar')

此导入有什么问题以及如何修复。
我在所有有关Spring JDBC框架的示例中都看到了这种导入。

What's wrong with this import and how to fix it. This kind of import I've seen in all examples about Spring JDBC framework.

推荐答案

转到构建路径设置eclipse中的项目。删除JRE系统库。再次添加。这应该可以解决您的错误。

Go to build path settings of your project in eclipse. Remove JRE system library. Add it again. This should resolve your error.

这篇关于错误:访问限制:类型“ DataSource”不是API(对所需库..\rt.jar的限制)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆