我试图配置没有persisten.xml文件的LocalContainerEntityManagerFactoryBean.
这是我的dataSource - 它适用于Hibernate SessionFactory - 所以,没关系.
<bean id="dataSource"
class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/test"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
这是我的LocalContainerEntityManagerFactoryBean
<bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="application.models" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
我得到的一个例外:
...Could not instantiate bean class [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]: Constructor threw exception; nested exception is java.lang.IllegalStateException: Failed to determine Hibernate PersistenceProvider
Run Code Online (Sandbox Code Playgroud)
我阅读文档,我知道LocalContainerEntityManagerFactoryBean有这样的属性,类似的创建LocalContainerEntityManagerFactoryBean的风格在Spring in Action 3和这里工作:http://softwarecave.org/2014/03/15/using-jpa-and-jta-与弹簧/
也许你知道我做错了什么,或者至少春天想通过这个例外告诉我什么?
在此先感谢,干杯:) …
我在ListFragment中实现了OnScrollListener接口,我希望在列表的最后一个元素可见时更改文本,但它不起作用.我没有找到类似问题的例子(ListFragment中的OnScrollListener).我的例子:
public class MyListFragment1 extends ListFragment implements OnScrollListener {
public View view;
public class MyListAdapter extends ArrayAdapter<String> {
Context myContext;
List<String> lista;
public MyListAdapter(Context context, int textViewResourceId,
List<String> objects) {
super(context, textViewResourceId, objects);
myContext = context;
lista = objects;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
//return super.getView(position, convertView, parent);
LayoutInflater inflater =
(LayoutInflater)myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row=inflater.inflate(R.layout.row, parent, false);
TextView label=(TextView)row.findViewById(R.id.month);
label.setText(lista.get(position));
ImageView icon=(ImageView)row.findViewById(R.id.icon);
//Customize your icon here
icon.setImageResource(R.drawable.ic_launcher);
return row;
}
}
@Override
public void onCreate(Bundle …Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试使用康康,但我有非常恼人的错误,即:未初始化的恒定版
对于控制器:
class EditionsController < ApplicationController
before_filter :authenticate_user! #devise
load_and_authorize_resource
def index
end
end
Run Code Online (Sandbox Code Playgroud)
这条路线:
get "editions/index"
Run Code Online (Sandbox Code Playgroud)
和这样的能力:
user ||= User.new # guest user (not logged in)
if user.has_role? "admin"
can :manage, Edition
cannot :commission
else
can :read, :commission
end
Run Code Online (Sandbox Code Playgroud)
还有一个问题,我如何为奇异(名称)控制器创建cancan能力?例如PhotoController