Error: Access restriction: The type 'DataSource' is not API (restriction on required library ..\rt.jar) [duplicate]

自作多情 提交于 2020-07-30 03:07:52

问题


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

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

This is my example

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);
       }

}

But I got the problem with

import javax.sql.DataSource

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

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.


回答1:


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



来源:https://stackoverflow.com/questions/29911795/error-access-restriction-the-type-datasource-is-not-api-restriction-on-requ

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!