mybatis报错org.apache.ibatis.binding.BindingException:

发布网友 发布时间:2022-04-24 14:30

我来回答

2个回答

热心网友 时间:2022-05-03 00:49

原因:缺少xml文件造成的。

1、在pom.xml build标签内加入 resources配置,不过滤配置文件即可,首先输入代码:

 <build>

<!--将mapper文件打包进去-->

<resources>

<resource>

                <!--指定根目录 到源文件夹 一般如下-->

<directory>src/main/java</directory>

2、然后输入下方的代码:

<includes>

<include>**/*.properties</include>

<include>**/*.xml</include>

</includes>

<filtering>false</filtering>

</resource>

</resources>

</build>

3、然后重新编译,出现xml文件,运行正常。

热心网友 时间:2022-05-03 02:07

import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.google.gson.reflect.TypeToken;
import com.lingnet.app.tv.R;
import com.lingnet.app.tv.adapter.LeftTypeListAdapter;
import com.lingnet.app.tv.adapter.TopTypeListAdapter;
import com.lingnet.app.tv.adapter.VenueAdapter;
import com.lingnet.app.tv.bean.BaseBean;
import com.lingnet.app.tv.constant.Const;
import com.lingnet.app.tv.constant.RequestType;
import com.lingnet.app.tv.view.SpacesItemDecoration;
import com.yanzhenjie.recyclerview.swipe.SwipeItemClickListener;
import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Call;

/**
 */
public class TvWisdomVenueFragment extends BaseFragment {

    @BindView(R.id.recyclerview_navi_left)
    RecyclerView recyclerViewLeft;
    @BindView(R.id.recyclerview_navi_top)
    RecyclerView recyclerViewTop;
    TopTypeListAdapter mTopTypeListAdapter;
    LeftTypeListAdapter mLeftTypeListAdapter;

    @BindView(R.id.recyclerview)
    SwipeMenuRecyclerView recyclerView;
    VenueAdapter venueAdapter;

    int currentPage = 0;
    String categoryId = "";


    public TvWisdomVenueFragment() {
        // Required empty public constructor
    }

    /**
     */
    public static TvWisdomVenueFragment newInstance() {
        TvWisdomVenueFragment fragment = new TvWisdomVenueFragment();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View v = inflater.inflate(R.layout.fragment_tv_wisdom_venue, container, false);
        ButterKnife.bind(this, v);
        initRecyclerViewRecommand();
        sendTypeRequest();
        return v;
    }

    private void initRecyclerViewRecommand() {

        HashMap<String, Integer> stringIntegerHashMap = new HashMap<>();
        stringIntegerHashMap.put(SpacesItemDecoration.TOP_DECORATION, 0);//top间距
        stringIntegerHashMap.put(SpacesItemDecoration.BOTTOM_DECORATION, 0);//底部间距
        stringIntegerHashMap.put(SpacesItemDecoration.LEFT_DECORATION, 0);//左间距
        stringIntegerHashMap.put(SpacesItemDecoration.RIGHT_DECORATION, 0);//右间距
        SpacesItemDecoration itemDecoration = new SpacesItemDecoration(stringIntegerHashMap);


        final GridLayoutManager  mGridLayoutManager=new GridLayoutManager(mActivity,2);
        recyclerView.setLayoutManager(mGridLayoutManager);
        recyclerView.setHasFixedSize(true);
        recyclerView.setItemAnimator(null);
        recyclerView.setNestedScrollingEnabled(false);
//        recyclerView.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(mActivity, R
//                .color.divider)));
        recyclerView.setSwipeItemClickListener(new SwipeItemClickListener() {
            @Override
            public void onItemClick(View itemView, int position) {
                Map<String, String> data = venueAdapter.dataList.get(position);
                Bundle bundle = new Bundle();
                bundle.putString("id", data.get("id"));
                startNextActivity(bundle, ChanggDetailActivity.class);
            }
        });
//        recyclerView.useDefaultLoadMore();
//        recyclerView.setLoadMoreListener(mLoadMoreListener);
        venueAdapter = new VenueAdapter(mActivity);
        venueAdapter.setHasStableIds(true);
        recyclerView.setAdapter(venueAdapter);
        recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                if(newState == RecyclerView.SCROLL_STATE_IDLE){
                    int lastVisiblePosition = mGridLayoutManager.findLastVisibleItemPosition();
                    if(lastVisiblePosition >= mGridLayoutManager.getItemCount() - 1){
                        currentPage++;
                        sendRequest();
//                        System.out.println("====自动加载");
                    }
                }
            }
        });
        //
        recyclerViewLeft.setLayoutManager(new LinearLayoutManager(mActivity));
        recyclerViewLeft.setHasFixedSize(true);
        recyclerViewLeft.setNestedScrollingEnabled(false);
        recyclerView.addItemDecoration(itemDecoration);
        mLeftTypeListAdapter = new LeftTypeListAdapter(mActivity);
        mLeftTypeListAdapter.setmIOnLeftClicListener(new LeftTypeListAdapter.IOnLeftClicListener() {
            @Override
            public void onLeftClick(int post) {
                mLeftTypeListAdapter.setSelectPos(post);
                mLeftTypeListAdapter.notifyDataSetChanged();

                Map<String, String> data = mLeftTypeListAdapter.dataList.get(post);
                categoryId = data.get("name");
                onRefresh();
            }
        });
        recyclerViewLeft.setAdapter(mLeftTypeListAdapter);
        //
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mActivity, LinearLayoutManager.HORIZONTAL,
                false);
        recyclerViewTop.setLayoutManager(linearLayoutManager);
        recyclerViewTop.setHasFixedSize(true);
        recyclerViewTop.setNestedScrollingEnabled(false);

        mTopTypeListAdapter = new TopTypeListAdapter(mActivity);
        recyclerViewTop.setAdapter(mTopTypeListAdapter);
    }

    /**
     * 加载更多。
     */
    private SwipeMenuRecyclerView.LoadMoreListener mLoadMoreListener = new SwipeMenuRecyclerView.LoadMoreListener() {
        @Override
        public void onLoadMore() {
            currentPage++;
            sendRequest();
        }
    };

    private void onRefresh() {
        venueAdapter.notifyDataSetChanged(null);//先清空数据
        currentPage = 0;
        sendRequest();
    }

    private void sendTypeRequest() {
        Call<BaseBean> call = client.venueCategoryzh();
        sendRequest(call, RequestType.venueCategoryzh, false);
    }

    private void sendRequest() {
        Map<String, String> params = new HashMap<>();
        params.put("pageSize", "" + Const.PAGESIZE);
        params.put("pageIndex", "" + currentPage);
        params.put("categoryId", categoryId);
        Call<BaseBean> call = client.venueList(params);
        sendRequest(call, RequestType.venueList, true);
    }

    @Override
    public void requestCallBack(String dataJson, RequestType type) {
        switch (type) {
            case venueCategoryzh:
                Map<String, String[]> data = mGson.fromJson(dataJson, new TypeToken<Map<String, String[]>>() {
                }.getType());
                String[] types = data.get("name");
                if (types != null && types.length > 0) {
                    categoryId = types[0];
                    List<Map<String, String>> dataList = new ArrayList<>();
                    for (String s : types) {
                        Map<String, String> temp = new HashMap<>();
                        temp.put("name", s);
                        dataList.add(temp);
                    }
                    mLeftTypeListAdapter.setSelectPos(0);
                    mLeftTypeListAdapter.notifyDataSetChanged(dataList);
                }
                sendRequest();
                break;
            case venueList:
                List<HashMap<String, String>> dataList = mGson.fromJson(dataJson, new
                        TypeToken<List<HashMap<String, String>>>() {
                        }.getType());
                venueAdapter.notifyDataSetChanged(dataList);

                recyclerView.loadMoreFinish((dataList == null || dataList.size() == 0), true);
                break;
        }
    }

    @Override
    public void requestFailed(String error, RequestType type) {
        recyclerView.loadMoreError(0, "请求网络失败");
    }

}

追问我想知道,你的那个解答和我提问的有关系吗?

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com