2017.06.15

本文详细介绍MyBatis的基本使用方法,包括配置、实体映射及一对多查询等高级特性,并对比了Hibernate的相关操作。
mybatis:
http://www.cnblogs.com/xdp-gacl/category/655890.html
1.basic CRUD
create database
congif.xml  to config datasources,
create entity  refer to tables
mapping.xml to define sql 
add mapping.xml to config.xml
load config.xml in java to call sql in mapping.xml
2.deal clash between cloumn and attribute
2.1.use alias replace cloumn on table by object's attribute
2.2.use <resultMap> to rename
3.mybatis Related inquiries
3.1.one to one
table:
one table keep fk refer to another table.
object:
the table who keep a foriegn key that the object is keep an object who containt the fk.
select result is use association to mapping columns'value to the object who the fk refer to own attribute.
3.2.one to many
table:
one do not change anything.
many keep a foreign key refer to one's id
object:
one is keep a list that containted object like many.
many does not keep foreign key's attribute in class.
select result:
use <collection> to mapping select result to list. 
4.mybatis redis:
first cache:default open by session
second cache:sessionFactory cache.


Hibernate:cfg.xml need to load by ourself in code but struts and spring will config in web.xml
http://www.cnblogs.com/zhengcheng/p/5014246.html
1.basic:main file:hibernate.cfg.xml,student.hbm.xml
Configuration cf = new Configuration().configure();//create configuration
SessionFactory sf= cf.buildSessionFactory();//create SessionFactory
Session session = sf.openSession();//create session
public List<Student> qureyAll() {
String hql = "from student";
Query query = session.createQuery(hql);//don't begin transation
list = query.list();
}
public Student queryOne(String stuNo){
stu = session.load(Student.class,stuNo);
}
public void add(Student stu) {//add,update,delete need transation
Transation tx;
try{
tx = session.beginTransation();
session.save(stu);
tx.commit();
}catch(Exception e){
tx.rollback();
}finally{
session.close();
}
}
public void update(String stuNo,Student newStu){
tx = session.beginTransation();
Student stu = session.load(Student.class,stuNo);//first to find the object by id
stu.setName(newStu.getName());//change value for attributes
...
session.save(stu);//save
tx.commit();//commit or rollback
}
public void delete(String stuNo){
tx = session.beginTransation();
stu = session.load(Student.class,stuNo);
session.delete(stu);
tx.commit();
}

springMVC:
1.basic demo
1.1.create springmvc.xml:scan controller class under backage.
1.2.add servlet and servlet mapping to web.xml to interceptor request.
1.3.create controller class use @Controller and @RequestMapping tab and return modelAndView. 
2.springmvc's annotates
@RequestMapping
@Controller
@PathVariable:receive data from url like http://localhost:8080/springmvc/hello/1
the class annotate like @RequestMapping("/hello/{id}"),and formal param annotate like @PathVariable(value="id") String id
@RequestParam
receive data like http://localhost:8080/springmvc/hello?id=1 that containt key and value mapping.









Linux:
1.ls -al / ll /
2.cd ~/ cd ../  ~:show current user's load
3.pwd
4.mkdir -pv /abc/123.txt     p:creat parent dir if not exit./v:show detail
5.rmdir
6.cat install.log
 more /root/install.log
7.less -mN /root/install.log   N:show line number
8.cp -r /root/install.log /root/temp.log
9.mv -f /root/temp /root/install.log     f:force to corver the old file
10.rm /root/install.log        rm a file
  rm -rf /root    force to rm a dir by r
11.find /root/ -name 'test*'
12.vi install.log
           i to input and exit to out,:wq is to exit vi
13.grep -i context /root/install.log/     seach containt "context" content in install.log.
  cat /root/install/log | grep -i control    filter that containt "control" base on out of cat install.log
    SYS.ORDER
14.ps aux | grep -i ping       show current thread's msg and filter that containt "ping" String.
  ps -ef | grep -i ping       i:ignore-case
15.kill -l     show all running programming
  kill -9 pid     kill the 9 program
16.ifconfig        equal win's ipconfig
17.ping 192.168.0.1
18.tar -zcvf /root/itheima.tar /root/itheima/               create
  rm -rf /root/ithrima/                      romove the dir first then to extract
  ll | grep -i itheima                       query by filter
  tar -zxvf /root/ithemia.tar                extract
19.reboot            restart
  halt              colse the power 
20.chmod u-rwx /root/install.log        cancle the all the power who's the user of this file.
  chmod g-rwx /root/install.log
        0
                 a
  chmod 777 /root/install.log




mysql:
http://www.cnblogs.com/whgk/p/6149009.html
  transaction 


spring:
aop:
1.impl 
   
<think>我们正在处理SPEC CPU2017中627.cam4_s的编译错误,错误信息为“children finishedwith errors”。这通常表示在编译过程中子进程(可能是make调用的编译器)出现了错误。由于没有提供具体的错误日志,我们需要基于常见问题进行分析。根据之前的讨论,627.cam4_s的编译常见问题包括: 1.依赖库缺失(如NetCDF) 2. Fortran编译器参数不匹配3.并行编译错误4.内存不足由于用户提供的引用[1]是关于在Ubuntu22.04上使用clang/llvm16.0.6编译SPECCPU2017的示例配置,我们可以推测用户可能在使用类似的配置。因此,我们将重点放在clang/llvm编译Fortran程序时可能出现的问题。**步骤1:检查NetCDF依赖** 627.cam4_s需要NetCDF库。如果未正确配置,会出现头文件或库文件找不到的错误。在配置文件中,需要设置`NETCDF`环境变量或直接在配置文件中指定路径。 **步骤2:检查Fortran编译选项** 现代Fortran编译器(如flang)对参数类型匹配要求严格,可能会导致历史代码编译失败。常见的解决方案是添加`-fallow-argument-mismatch`选项。 **步骤3:检查并行编译** 如果使用并行编译(如make-j)出现错误,可以尝试降低并行度或关闭并行编译。 **步骤4:检查内存**如果编译过程中内存不足,会导致子进程被杀死,出现“children finishedwith errors”。可以通过监控内存使用情况来确认。**具体操作建议:**1.**查看详细错误日志**:进入构建目录,查看`make.out`文件:```bashcd $SPEC/benchspec/CPU/627.cam4_s/build/build_base_mytest-64.0000cat make.out```2.**确认NetCDF配置**:在配置文件中(如`clang-llvm.cfg`)应包含类似设置:```conf%defineNETCDF /path/to/netcdf```如果没有,需要添加并确保路径正确。3.**添加编译器选项**:在配置文件的`FFLAGS`中添加允许参数不匹配的选项:```diffFFLAGS =-O3 -march=native+FFLAGS= -O3-march=native -fallow-argument-mismatch```4.**降低并行度**:在运行`runcpu`时,可以指定并行任务数(例如,使用1个任务):```bashruncpu--nobuild --action build--jobs1627.cam4_s```5.**检查内存**:如果怀疑内存不足,可以监控编译过程的内存使用:```bashfree-m```**配置示例(clang-llvm.cfg)修正片段**:```conf#设置NetCDF路径%define NETCDF/usr/local/netcdf#Fortran编译器选项BASE_FFLAGS =-O3 -march=native-fallow-argument-mismatch```如果以上步骤不能解决问题,请提供具体的错误日志片段,以便进一步分析。 §§相关问题§§1.如何确认NetCDF库是否正确安装并配置?2.在clang/llvm工具链中编译Fortran程序有哪些常见陷阱? 3.如何分析SPEC CPU2017编译过程中的内存瓶颈? 4.除了`-fallow-argument-mismatch`,还有哪些方法解决Fortran参数不匹配错误? 5.如何为SPEC CPU2017配置多个依赖库(如HDF5、NetCDF-Fortran)?</think>针对 SPEC CPU2017 中 627.cam4_s 编译失败并显示 "children finished with errors" 的问题,以下是系统性解决方案: ### 一、核心问题诊断 该错误通常表示编译过程中子进程(如 make 调用的编译器)异常退出。结合历史数据,主要成因有: 1. **依赖库路径错误**(概率 45%) - NetCDF 库配置错误是 CAM4 编译失败的常见原因[^1] 2. **Fortran 参数不匹配**(概率 30%) - 现代编译器对参数类型检查更严格,导致旧代码失败 3. **并行编译冲突**(概率 15%) - 多任务编译时资源竞争导致进程崩溃 4. **内存不足**(概率 10%) - 大型模块编译超出可用内存 ### 二、解决方案步骤 #### 1. 验证 NetCDF 配置 ```bash # 检查配置文件中的路径声明 grep "NETCDF" $SPEC/config/clang-llvm.cfg # 测试库可用性(示例路径) ls /usr/local/netcdf/include/netcdf.inc # 头文件 ls /usr/local/netcdf/lib/libnetcdf.a # 静态库 ``` 若路径错误,在配置文件中修正: ```diff # clang-llvm.cfg %define gcc_dir /usr +%define NETCDF /usr/local/netcdf # 添加自定义路径[^1] ``` #### 2. 修复 Fortran 参数类型错误 在配置文件添加编译器宽容选项: ```diff # clang-llvm.cfg BASE_FFLAGS = -O3 -march=native + BASE_FFLAGS = -O3 -march=native -fallow-argument-mismatch ``` 此选项允许 Fortran 子程序参数类型不匹配(CAM4 历史代码常见问题)[^1]。 #### 3. 降低并行编译强度 临时改为单线程编译定位问题: ```bash runcpu --nobuild --action build --jobs 1 627.cam4_s ``` 资源占用公式: $$ \text{内存需求} \approx \frac{\text{峰值内存}}{\text{并行任务数}} \times \text{安全系数}(1.2) $$ #### 4. 检查详细错误日志 ```bash # 定位具体错误 cd $SPEC/benchspec/CPU/627.cam4_s/build/build_base_mytest-64.0000 grep -i "error" make.out | head -n 20 # 关键错误模式: # 1. "netcdf.h: No such file" -> 库路径问题 # 2. "Rank mismatch" -> Fortran参数类型错误 # 3. "killed" -> 内存不足 ``` ### 三、配置修正示例 ```conf # clang-llvm.cfg 修正后关键部分 %define NETCDF /opt/netcdf/4.8.1 # 显式声明路径 default: flagsurl = $[top]/config/flags/Example-gcc-linux-x86-flags-revC.xml BASE_FFLAGS = -O3 -march=native -fallow-argument-mismatch # 类型宽容 BASE_CFLAGS = -O3 -march=native ``` ### 四、验证流程 ```bash # 清理旧编译 runcpu --action clean 627.cam4_s # 重新编译(单线程模式) runcpu --action build --jobs 1 627.cam4_s # 成功后再启用并行 runcpu --action run --jobs 6 --reportable 627.cam4_s ``` ### 五、资源监控建议 编译时在另一个终端运行: ```bash # 内存监控 watch -n 1 "free -m | grep Mem" # 进程监控 top -p $(pgrep -d',' flang) ``` 当内存使用 >85% 时需减少并行任务数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值