发包时候一般需要验证是否正确版本
通过脚本在classes目录下生成一个version.txt文件
并在程序中提供version接口
import java.io.IOException;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.arcsoft.web.openapi.common.basic.BaseController;
@RestController
@RequestMapping("/rest/service/version")
public class VersionController extends BaseController{
@RequestMapping(value = "/versionInfo", method = RequestMethod.GET)
@ResponseBody
public Object versionInfo() throws Exception{
ClassPathResource res = new ClassPathResource("version.txt");
String ret = "unknown, version.txt does not exist!!!";
if(res.exists()){
List<String> retList = null;
try{
retList = IOUtils.readLines(res.getInputStream());
ret = retList.get(0);
}catch(IOException e){
e.printStackTrace();
}
}
return ret;
}
}