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

编程教程 > Java (2957) 2024-11-26 14:39:04
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;
	}
	
}


评论
User Image
提示:请评论与当前内容相关的回复,广告、推广或无关内容将被删除。

相关文章
eclipse如何关闭java代码中某些部分/片段代码不被格式化,eclipse,代码部分不被格式化,How to turn off the Eclipse code formatter for...
Vert.x java 入门,Vert.x这个框架在常规的web业务开发中估计还不是很成熟。但是了解了他的一些原理我觉得可以有一番作为。今天主要简单讲解下eclipse Vert.x是什么有什么...
eclipse复制高亮代码到word中
1.启动eclipse2.安装m2eclipse插件新版的eclipse已经默认包含m2eclipse插件,点击菜单中的Window-&gtl;Preferences看
Java编程之通过eclipse创建maven自定义项目原型模板(Archetype),Java编程,maven自定义项目模板
Remote System Explorer Operation导致eclipse慢或者卡死eclipse解决,eclipse
Java编程之spring boot FastDFS Java client使用,Java编程,FastDFS Java客户端
java8 Function 应用场景 --代码重构旧代码: import org.springframework.beans.BeanUtils; import java.util.func...
Java编程软件有哪些?常用Java编程软件下载、安装和使用说明
Java编程之Spring Cloud Hystrix Circuit熔断/断路
eclipse启动报错"reload maven project' has encountered a proble" 解决方法,怎么办?
问题描述idea启动maven的JavaFX项目报错:Exception in Application start method java.lang.reflect.InvocationTarg...
Java如何复制目录,Java基础教程系列,如果要将目录及其包含的所有子文件夹和文件从一个位置复制到另一个位置,请使用下面的代码,该代码使用递归遍历目录结构,然后使用Files.copy()函数...
随着工作时间的推移,参加过的面试也是挺多的。记录下参与面试中的一些经典代码阅读题。
java编程之maven打包Java source jar包