1:Eclipse安装sts插件
通过eclipce市场安装Spring Tool Suite (STS) for Eclipse插件
安装sts插件后eclipse的navigator菜单失效,Project Explorer无法显示.
java.lang.NoClassDefFoundError: org/springframework/ide/eclipse/beans/core/model/IBeansConfig
解决方法1:卸载STS
解决方法2:待定
2:Spring Tool Suite下载地址
https://spring.io/tools/sts/legacy.
http://spring.io/tools/sts/all
一个独立的spring开发工具,一个被包装过的eclipse
Spring Boot官网:http://projects.spring.io/spring-boot/
3:通过网址安装sts插件
http://dist.springsource.com/release/TOOLS/update/e4.5/
http://dist.springsource.com/release/TOOLS/update/e3.7/
4:spring boot官方地址
http://docs.spring.io/spring-boot/docs/1.5.2.RELEASE/reference/htmlsingle/#getting-started
5:spring boot cli
执行符合spring的groovy脚本工具。可以快速搭建一个demo系统。demo使用groovy编写脚本,然后可以使用Spring CLI直接运行
6:git库
https://github.com/spring-projects/spring-boot
7:开发IDE
使用eclipse+mvn插件开发
8:配置jdbctemplate访问数据库
在application.properties中配置
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=11111
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
在代码中引用 jdbcTemplate即可@Autowired
private JdbcTemplate jdbcTemplate;
9:配置sessionFactory访问数据库
或者1定义
@Autowired
private EntityManagerFactory entityManagerFactory;
@Bean
public SessionFactory getSessionFactory() {
if (entityManagerFactory.unwrap(SessionFactory.class) == null) {
throw new NullPointerException("factory is not a hibernate factory");
}
return entityManagerFactory.unwrap(SessionFactory.class);
}
引用
private SessionFactory sessionFactory;
或者2在属性配置文件中配置(可有可无)
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext
并且在java代码中编码@Bean
public HibernateJpaSessionFactoryBean sessionFactory() {
return new HibernateJpaSessionFactoryBean();
}
@Autowired
private SessionFactory sessionFactory;
或者3在属性配置文件中配置(可有可无)
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext
并且在java代码中编码@Bean
public SessionFactory sessionFactory(HibernateEntityManagerFactory hemf) {
return hemf.getSessionFactory();
}
@Autowired
private SessionFactory sessionFactory;
Spring事务参考资料
http://docs.spring.io/spring/docs/2.5.x/reference/transaction.html
http://docs.spring.io/spring/docs/3.2.18.RELEASE/spring-framework-reference/htmlsingle/#transaction