簡體   English   中英

Eclipse導入org.hibernate無法解析

[英]Eclipse The import org.hibernate cannot be resolved

我是Android SDK的新手。 我正在嘗試使用休眠/標准,但它給出了一個錯誤。

我已經按照以下步驟安裝了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!"));
    }

您需要將Hibernate Jar添加到項目類路徑或Eclipse庫列表中。

另外,通過添加“幫助”->“安裝新軟件”,您將添加用於Eclipse的Hibernate插件,而不是將Hibernate lib添加到您的Eclipse項目中。

以下是一些將jar添加到eclipse項目或classpath的鏈接:

如何在Eclipse中導入jar

http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM