Eclipse无法解析导入org.hibernate

7xzttuei  于 11个月前  发布在  Eclipse
关注(0)|答案(2)|浏览(158)

我对Android SDK很陌生。我试图使用Hibernate/Criteria,但它给出了一个错误。
我已经按照这些步骤安装了Hibernate。

Help -> Install New Software
Click on Add. Location: http://download.jboss.org/jbosstools/updates/stable/
Inside JBoss Web and Java EE Development folder, select Hibernate Tools
Click on Next

字符串
我可以看到Hibernate已经安装在Eclipse中,但为什么错误一直显示?

import org.hibernate.Criteria;
Criteria criteria = new Criteria();


误差

The import org.hibernate cannot be resolved


文件

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import com.google.android.gms.maps.*;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import android.location.Location;
import android.location.LocationManager;

import android.widget.Toast;
import android.util.Log;

import org.hibernate.Criteria; 

public class MyMapActivity extends Activity {
    GoogleMap googleMap; 

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_map);
        setUpMap();
    }

    private void setUpMap() {
        // Enable MyLocation Layer of Google Map
        googleMap.setMyLocationEnabled(true);

        // Get LocationManager object from System Service LOCATION_SERVICE
        LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

        // Create a criteria object to retrieve provider
        Criteria criteria = new Criteria(); //THIS IS WHERE THE ERROR IS

        // Get the name of the best provider
        String provider = locationManager.getBestProvider(criteria, true);

        // Get Current Location
        Location myLocation = locationManager.getLastKnownLocation(provider);

        //set map type
        googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);

        // Get latitude of the current location
        double latitude = myLocation.getLatitude();

        // Get longitude of the current location
        double longitude = myLocation.getLongitude();

        // Create a LatLng object for the current location
        LatLng latLng = new LatLng(latitude, longitude);      

        // Show the current location in Google Map        
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

        // Zoom in the Google Map
        googleMap.animateCamera(CameraUpdateFactory.zoomTo(20));
        googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title("You are here!"));
    }

jhkqcmku

jhkqcmku1#

您需要将Hibernate Jar添加到项目类路径或Eclipse库列表中。
此外,通过添加Help-> Install New Software,您正在为Eclipse添加Hibernate插件,而不是将Hibernate lib添加到您的Eclipse项目中。
以下是一些将jar添加到Eclipse项目或类路径的链接:
How to import a jar in Eclipse
http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29

tez616oj

tez616oj2#

伙计们首先去添加你的配置(buildpath)在jar.files;并检查maven存储库点击访问,liber,像这样,并添加所有的路径位置,然后它的明确elseif(u可以清除这是在自动错误修复建议在您的eclipse时,跟踪完整的错误代码在eclipse),然后去修复安装和添加jar
最后一个方法:使用解决这个问题的简单方法,它只不过是使用你的com.dao或anyname类作为com.hibernate;

相关问题