Eclipse使用 junit测试 报 “The builder launch configuration could not be found” 错误的解决办法

 eclipse, junit  Eclipse使用 junit测试 报 “The builder launch configuration could not be found” 错误的解决办法已关闭评论
4月 112022
 

Eclipse使用 junit测试, 报 “The builder launch configuration could not be found” 错误

解决方法如下:

  1. Package Explorer 视图下选中项目名
  2.  右键项目名,然后选择Properties 或者 在Eclipse 工具栏中选择 Project -> Properties
  3. 弹出的 Properties 对话框中,点击 Builders
  4. 将没有勾选,缺失的 builder 移除掉
  5. 点击 OK 按钮

DONE!

ibatis 里出现错误 “could not find sql statement to include with refid xxx”

 java, mybatis  ibatis 里出现错误 “could not find sql statement to include with refid xxx”已关闭评论
4月 112022
 

ibatis 测试时出现错误提示:  “could not find sql statement to include with refid xxx” , 出现这种错误一般是下面两种情况引起:

  1. refid引用的sqlid不正确, 自己好好检查下。
  2. refid正确,但还是报错, 可能原因是: sql refid定义的位置必须在引用的语句之前,否则会出错。

 

DONE!

nginx 403 forbidden, Permission denied 错误处理方法

 nginx  nginx 403 forbidden, Permission denied 错误处理方法已关闭评论
7月 052020
 

nginx配置好后端网站配置文件后,提示 403 forbidden 的问题,这个问题其实是很常见的问题,一般都是由以下4个方面的原因引起的:

 

一、由于启动用户和nginx工作用户不一致所致

1.1查看nginx的启动用户,发现是nobody,而实际用root启动的

ps aux | grep "nginx: worker process" | awk'{print $1}'

1.2将nginx.config的user改为和启动用户一致,

vi conf/nginx.conf

 

二、缺少index.html或者index.php文件,就是配置文件中index index.html index.htm这行中的指定的文件。
    server {
      listen       80;
      server_name  localhost;
      index  index.php index.html;
      root  /data/www/;
    }

如果在/data/www/下面没有index.php,index.html的时候,直接文件,会报403 forbidden。

三、权限问题,如果nginx没有web目录的操作权限,也会出现403错误。

解决办法:修改web目录的读写权限,或者是把nginx的启动用户改成目录的所属用户,重启Nginx即可解决

   chmod -R 777 /data
   chmod -R 777 /data/web/
四、SELINUX设置为开启状态(enabled)的原因。

4.1、查看当前selinux的状态。

    /usr/sbin/sestatus

4.2、将SELINUX=enforcing 修改为 SELINUX=disabled 状态。

    vi /etc/selinux/config

    #SELINUX=enforcing
    SELINUX=disabled

4.3、重启生效。reboot。

    reboot

 

mybatis下limit有参数计算时的写法

 开发  mybatis下limit有参数计算时的写法已关闭评论
4月 232020
 

mybatis下limit如果想做分页,对limit做参数计算时:

错误的写法:

<select id=”queryMyApplicationRecord” parameterType=”MyApplicationRequest” resultMap=”myApplicationMap”>
SELECT
a.*,
FROM
tb_user a
WHERE 1=1
<if test=”ids != null and ids.size()!=0″>
AND a.id IN
<foreach collection=”ids” item=”id” index=”index”
open=”(” close=”)” separator=”,”>
#{id}
</foreach>
</if>
<if test=”statusList != null and statusList.size()!=0″>
AND a.status IN
<foreach collection=”statusList” item=”status” index=”index”
open=”(” close=”)” separator=”,”>
#{status}
</foreach>
</if>
ORDER BY a.create_time desc
LIMIT (#{pageNo}-1)*#{pageSize},#{pageSize}; // 错误
</select>
在MyBatis中LIMIT之后的语句不允许的变量不允许进行算数运算,会报错。

正确的写法一:
<select id=”queryMyApplicationRecord” parameterType=”MyApplicationRequest” resultMap=”myApplicationMap”>
SELECT
a.*,
FROM
tb_user a
WHERE 1=1
<if test=”ids != null and ids.size()!=0″>
AND a.id IN
<foreach collection=”ids” item=”id” index=”index”
open=”(” close=”)” separator=”,”>
#{id}
</foreach>
</if>
<if test=”statusList != null and statusList.size()!=0″>
AND a.status IN
<foreach collection=”statusList” item=”status” index=”index”
open=”(” close=”)” separator=”,”>
#{status}
</foreach>
</if>
ORDER BY a.create_time desc
LIMIT ${(pageNo-1)*pageSize},${pageSize}; (正确)
</select>
正确的写法二:(推荐)
<select id=”queryMyApplicationRecord” parameterType=”MyApplicationRequest” resultMap=”myApplicationMap”>
SELECT
a.*,
FROM
tb_user a
WHERE 1=1
<if test=”ids != null and ids.size()!=0″>
AND a.id IN
<foreach collection=”ids” item=”id” index=”index”
open=”(” close=”)” separator=”,”>
#{id}
</foreach>
</if>
<if test=”statusList != null and statusList.size()!=0″>
AND a.status IN
<foreach collection=”statusList” item=”status” index=”index”
open=”(” close=”)” separator=”,”>
#{status}
</foreach>
</if>
ORDER BY a.create_time desc
LIMIT #{offSet},#{limit}; (推荐,代码层可控)
</select>
分析:方法二的写法,需要再请求参数中额外设置两个get函数,如下:
@Data
public class QueryParameterVO {

private List<String> ids;

private List<Integer> statusList;

// 前端传入的页码
private int pageNo; // 从1开始

// 每页的条数
private int pageSize;

// 数据库的偏移
private int offSet;

// 数据库的大小限制
private int limit;

// 这里重写offSet和limit的get方法
public int getOffSet() {
return (pageNo-1)*pageSize;
}

public int getLimit() {
return pageSize;
}
}

 

升级完macOS mojave后,git命令出现xcrun 错误解决方法

 git, mac  升级完macOS mojave后,git命令出现xcrun 错误解决方法已关闭评论
3月 292019
 

今天升级macOS 到 macOS mojave,升级完后终端里使用git的时候,弹出一行错误:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

解决方法,重装xcode command line:

xcode-select --install

如果没有解决问题,执行以下命令

sudo xcode-select -switch /

DONE!!