eclipse如何关闭java代码中某些部分/片段代码不被格式化

位置:首页>文章>详情   分类: 教程分享 > Java教程   阅读(1654)   2023-03-28 11:29:14
eclipse如何关闭java代码中某些部分/片段代码不被格式化,eclipse,代码部分不被格式化,
How to turn off the Eclipse code formatter for certain sections of Java code?

1.设置eclipse开启Off/On tags

依次点击菜单
preferences->Java->Code Style->Formatter
点击Edit
1

找到tag,点击enable Off/On tags
2


在不想被格式化的代码之间添加以下注释标签即可
 
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import org.springframework.util.Base64Utils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.cqax.axschoolweb2.common.pojo.Result;

/**
 * 验证码公用处理类
 * 
 * @author xq
 *
 */
@RestController
public class ValidationCodeController {
	//@formatter:off
	/**
	 * 
	 * @api {get} /apis/validation/getcode.json 获取验证码
	 * 
	 * @apiName GetValidateCode
	 * 
	 * @apiGroup Validation
	 * 
	 * @apiParam {String} [timeStamp] 时间戳
	 * 
	 * @apiSuccessExample {String} 返回值: 
	 * {
    "id": "1be34f4a324c4123b0325ecf0593d70e",
    "data": {
        "image": "iVBORwCCAAAAAAAAAAAAAAAAA=="
    },
    "code": "00000",
    "dateTime": "2017-05-23 14:00:23",
    "msg": null
}
	 * 
	 */
	//@formatter:on
	@GetMapping("/apis/validation/getcode.json")
	public Result getCode() {
		try {
			InputStream is = new FileInputStream(new File("e:/2.png"));

			ByteArrayOutputStream bao = new ByteArrayOutputStream();

			byte[] cache = new byte[4096];
			while (is.read(cache) != -1) {
				bao.write(cache);
			}
			String rs = Base64Utils.encodeToString(bao.toByteArray());
			JSONObject obj = new JSONObject();
			obj.put("image", rs);

			is.close();

			return Result.success(obj);
		} catch (Exception e) {
			return Result.fail("eeeee", "错误,异常," + e.getMessage());
		}

	}

	//@formatter:off
	/**
	 * @api {get} /apis/validation/compare.json 对比验证码
	 * 
	 * @apiName CompareValidateCode
	 * 
	 * @apiGroup Validation
	 * 
	 * @apiParam {String} vcode 验证码
	 * 
	 * @apiSuccessExample {json} 返回值:
	 * {
    "id":"f47611a1a7ee4d4c8c0420a4f7e4b228",
    "data":{
        "result":true
    },
    "code":"00000",
    "dateTime":"2017-05-23 14:41:36",
    "msg":null
}
	 */
	//@formatter:on
	@GetMapping("/apis/validation/compare.json")
	public Result compare(String vcode) {

		JSONObject obj = new JSONObject();
		obj.put("result", true);// 对比结果
		return Result.success(obj);
	}

	
	
	public Result getPhoneCode(){
		JSONObject obj=new JSONObject();
		return null;
	}
	
}

标签: eclipse Java代码 Java
地址:https://www.leftso.com/article/172.html

相关阅读

eclipse如何关闭java代码中某些部分/片段代码不被格式化,eclipse,代码部分不被格式化,How to turn off the Eclipse code formatter for...
eclipse复制高亮代码到word中
Vert.x java 入门,Vert.x这个框架在常规的web业务开发中估计还不是很成熟。但是了解了他的一些原理我觉得可以有一番作为。今天主要简单讲解下eclipse Vert.x是什么有什么...
eclipse 构建maven项目,步骤详细易懂
Java编程之通过eclipse创建maven自定义项目原型模板(Archetype),Java编程,maven自定义项目模板
Remote System Explorer Operation导致eclipse慢或者卡死eclipse解决,eclipse
java8 Function 应用场景 --代码重构旧代码: import org.springframework.beans.BeanUtils; import java.util.func...
Java编程软件有哪些?常用Java编程软件下载、安装和使用说明
idea是继eclipse后又兴起的一款优秀的Java编程IED,本文主要讲解idea如何更换/下载主题
eclipse启动报错"reload maven project' has encountered a proble" 解决方法,怎么办?