maven,编译,代码过长

原来的项目经理在系统里写了个一万多行的枚举类。。。

用eclipse可以正常启动运作,但是用maven打包就会报错:代码过长。

有很多说法,但是我发现的最有价值的是这一段:

https://stackoverflow.com/questions/2546470/enum-exeeding-the-65535-bytes-limit-of-static-initializer-whats-best-to-do

Methods are not limited to 64K. There are other problems, such as that the exception table can only cover 64K, and that the most common jump instructions jump with 16 bits integers. But an enum static initializer doesn't need exception handlers and a better compiler knows to generate wide jump instructions. So it's really a limitation in Javac (number of enum constants - not in general), that can be fixed by just fixing javac. 

就是说enum不受64k的约束,聪明的编译器能绕过这个问题。

而maven默认值用了javac编译,没有对这里做优化,于是报错。

解决方法:

要么在maven配置中修改compiler plugin配置,换为其他编译器(然而我尝试之后还是不行)

要么直接在IDE里编译好,maven只负责打包,不要重复编译(在运行参数中加入-Dmaven.main.skip跳过编译检查)

你可能感兴趣的:(javaEE,maven)