1、
bug:
grails> 2017-02-20 20:19:20.621 ERROR --- [nio-2222-exec-1] o.g.web.errors.GrailsExceptionResolver : IllegalStateException occurred when processing request: [GET] /proj
No transactionManager was specified. Using @Transactional or @Rollback requires a valid configured transaction manager. If you are running in a unit test ensure the test
un the test suite not an individual test method.. Stacktrace follows:
解决方案:
删除@Transactioanl即可解决
2、依赖错误
bug:
compile和provided混乱
解决方案
对于scope=compile的情况(默认scope),也就是说这个项目在编译,测试,运行阶段都需要这个artifact对应的jar包在classpath中。
而对于scope=provided的情况,则可以认为这个provided是目标容器已经provide这个artifact。换句话说,它只影响到编译,测试阶段。在编译测试阶段,我们需要这个artifact对应的jar包在classpath中,而在运行阶段,假定目标的容器(比如我们这里的liferay容器)已经提供了这个jar包,所以无需我们这个artifact对应的jar包了。
3、log.info命令行没有信息
解决方案:
编辑logback.groovy文件将ERROR全部替换成INFO
4、idea 运行tomcat报re-import the Gradle project and try again
bug:
Error:Unable to make the module: cocacola-api-v1_main, related gradle configuration was not found. Please, re-import the Gradle project and try again.
解决方案:
IntelliJ 13 supports "refreshing" the Gradle project. When the project is refreshed any dependency changes are picked up as well as any changes to the project structure.
The specific command I used based on this answer: ctrl+shift+a then type "Refresh all external projects"
5、idea tomcat配置错误
bug:
Application Server was not connected before run configuration stop, reason: Unable to ping server at localhost:1099
解决方案:
Tomcat运行时JRE选择安装路径是JDK的安装路径,而非JRE安装路径,容易让人误解
6、idea 包引入不对
bug:先build再改dependencies,其中先build的只是一个比如groovy.net后改的是groovy.all
解决方案:删除.idea文件夹再重新oepn
7、tomcat服务器挂掉
bug:重启tomcat没有用,之前打开日志看的时候日志狂跑,然后自己用ctr+v终止了
解决方案:重启服务器,开机,不是tomcat,原因是日志太大把服务器内存耗尽了
8、中文编码出错,本地tomcat到服务器tomcat传数据中文乱码
bug:没有启动tomcat在代码里面的test里测试通过,然而启动tomcat然后浏览器或者postman发请求发现不能返回值
解决方案:打开日志查看发现前者服务器接收的请求正常,后者服务器接收的请求中文乱码,导致数据库读取出错,Tomcat的URIEncoding默认是ISO-8859-1,而我设置为UTF-8,主要是想解决中文命名的文件以及请求以get方式提交有可能出现的乱码问题。本地tomcat到服务器tomcat传数据中文乱码,但是不影响实际结果,因为war打包时发送到服务器上运行的,前端也是通过服务器获得数据
9、groovy函数默认最后一行返回,如果再加上一行println或者log.info用于调试,就使得返回值没有了
bug:前端显示请求成功,没有数据
解决方案:删除最后一行println或者log.info,使得函数可以有返回值
10、数据库连接没有设置连接池导致并发不够
bug:高并发导致tomcat宕机
解决方案:增加连接池,并查看log,查看宕机原因,增加log进行调试
11、全局变量使用不当
bug: class 里面 static http = new AsyncHTTPBuilder(poolSize: 30, uri: "https://10.212.36.41")为全局变量,导致class的方法里面再引用导致数据不一致
解决方案:处理好数据问题,最好的方法是使用局部变量。
12、hive导入数据文件名有下划线出错
bug:路径正确,导入方式正确,但是报错显示路径出错
解决方案:将文件名 mv /tmp/_load.csv /tmp/load.csv, 再load下,就成功了
13、spring cache使用不当
bug:spring cache没有生效
解决方案:首先方法必须是public类型,其次所有相关的service和controller引用时都必须加入spring bean进行管理,例如:
@Autowired
HttpClientService httpClientService
17、spring编码出错
bug:中文乱码
解决方案:通过spring默认是iso编码,需要改正为utf8
<!-- 处理请求时返回json字符串的中文乱码问题 -->
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=UTF-8</value>
</list>
</property>
<property name="writeAcceptCharset" value="false"/>
</bean>
</mvc:message-converters>