我的版本:oracle 10.2,jdk1.7,tomcat7,springside4.0
1.下载oracle jdbc驱动oracle官网或者网上搜索oracle 10.2对应版本的ojdbc14,或者最新的oracle 11的ojdbc6,虽然springside官网上提到要用ojdbc6支持jdk1.6的,经测试这两个都可以。
2.手动安装上面下载的jar包到maven本地仓库,调出cmd命令输入框:mvn install:install-file -DgroupId=com.ojdbc2 -DartifactId=ojdbc2 -Dversion=11.2.0 -Dpackaging=jar -Dfile=f:\ojdbc6.jar
(这个命令如果失败,可以搜索一下,也许是我手误写错了)
3.修改quickstart的pom:注释掉h2的,修改oralcle的。groupId,artifactId,version与上述的一致。
<jdbc.driver.groupId>com.ojdbc2</jdbc.driver.groupId>
<jdbc.driver.artifactId>ojdbc2</jdbc.driver.artifactId>
<jdbc.driver.version>11.2.0</jdbc.driver.version>
4.修改application.properties文件:注释与修改
jdbc.driver=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@localhost :1521:orcl
jdbc.username=sa
jdbc.password=sa
上述为:已经创建了数据库orcl,sa用户可以用普通身份登录并有增删改查权限。(这只是我个人的设置):
-- Create the user
create user SA
identified by ""
default tablespace USERS
temporary tablespace TEMP
profile DEFAULT;
-- Grant/Revoke role privileges
grant connect to SA;
grant oem_monitor to SA;
grant resource to SA;
-- Grant/Revoke system privileges
grant unlimited tablespace to SA;
5.修改实体类:springside官网文档有说明
User类:
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="UserSequence")
@SequenceGenerator(name = "UserSequence", sequenceName = "SEQ_USER", allocationSize=20)
public Long getId(){
return id;
};
Task类:
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="TaskSequence")
@SequenceGenerator(name = "TaskSequence", sequenceName = "SEQ_TASK", allocationSize=20)
public Long getId(){
return id;
};
6.到数据库区创建表:可以用plsql打开数据库,运行
create table ss_task (
id number(19,0),
title varchar2(128) not null,
description varchar2(255),
user_id int not null,
primary key (id)
);
create table ss_user (
id number(19,0),
login_name varchar2(64) not null unique,
name varchar2(64) not null,
password varchar2(255) not null,
salt varchar2(64) not null,
roles varchar2(255) not null,
register_date date not null,
primary key (id)
);
create sequence SEQ_USER start with 100 increment by 20;
create sequence SEQ_TASK start with 100 increment by 20;
注意:与springside自带的oracle脚本不同的地方有,
sqluser_id int not null,bigint改为了int
register_date date not null,register_date中原本少了个t
根据你的实体类上面的声明对应:
create sequence SEQ_USER start with 100 increment by 20;
create sequence SEQ_TASK start with 100 increment by 20;
7.运行测试:改完后,如果直接右击项目maven run as ,on sever的话,报各种错,我的为找不到sql.url。
clean up 也不行。然后我把项目右键delete,到该quickstart目录的bin下运行Eclipse,然后重新导入EClipse,再如果直接右击项目maven run as ,on sever,成功通过。
8.注意地方。其他的测试的配置还没改。