Open lijunyong opened 8 years ago
好像是因为,java -jar不允许对jar包进行修改,所以动态编译的class无法生成
感觉好像是classpath的设置问题,能发一下你的测试工程吗?我复现一下原因
@jhunters 能给个联系方式吗?我已经测试过了,如果把所有依赖包都打到一个jar中,通过java -jar运行,无法动态编译生成class文件。如果把依赖的jar打到外面的文件夹是可以的,https://github.com/Baidu-ecom/Jprotobuf-rpc-socket/issues/27
通过java -jar运行,我也遇到这种问题,怎么把把依赖的jar打到外面的文件夹。
@dai2y 你试试
<plugin>
<groupId>com.baidu</groupId>
<artifactId>jprotobuf-precompile-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
<filterClassPackage>com</filterClassPackage>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>precompile</goal>
</goals>
</execution>
</executions>
</plugin>
不行参考:https://github.com/baidu/Jprotobuf-rpc-socket/issues/27
[ WARN ] [2016-09-12 19:26:29] org.springframework.beans.factory.support.DefaultListableBeanFactory [1480] - Bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'idGeneratorService' defined in URL [jar:file:/G:/payment-platform/payment-cpcn/payment-cpcn-server/payment-cpcn-server-1.0-SNAPSHOT.jar!/lib/id-generator-client-1.1.0-SNAPSHOT.jar!/id-generator-client.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Compilation failed. class: com.omniprimeinc.commonservice.idgen.redis.model.ID$$JProtoBufClass, diagnostics: [ID$$JProtoBufClass.java:2: 错误: 程序包com.google.protobuf不存在 import com.google.protobuf.; ^, ID$$JProtoBufClass.java:4: 错误: 程序包com.baidu.bjf.remoting.protobuf.utils不存在 import com.baidu.bjf.remoting.protobuf.utils.; ^, ID$$JProtoBufClass.java:6: 错误: 程序包com.baidu.bjf.remoting.protobuf不存在 import com.baidu.bjf.remoting.protobuf.*; ^, ID$$JProtoBufClass.java:8: 错误: 找不到符号 import com.omniprimeinc.commonservice.idgen.redis.model.ID; ^ 符号: 类 ID 位置: 程序包 com.omniprimeinc.commonservice.idgen.redis.model, ID$$JProtoBufClass.java:9: 错误: 程序包com.baidu.bjf.remoting.protobuf不存在 public class ID$$JProtoBufClass implements com.baidu.bjf.remoting.protobuf.Codec {
^, ID$$JProtoBufClass.java:9: 错误: 找不到符号
public class ID$$JProtoBufClass implements com.baidu.bjf.remoting.protobuf.Codec {
^
符号: 类 ID
位置: 程序包 com.omniprimeinc.commonservice.idgen.redis.model, ID$$JProtoBufClass.java:10: 错误: 程序包com.google.protobuf.Descriptors不存在
private com.google.protobuf.Descriptors.Descriptor descriptor;
^, ID$$JProtoBufClass.java:11: 错误: 找不到符号
public byte[] encode(com.omniprimeinc.commonservice.idgen.redis.model.ID t) throws IOException {
^
符号: 类 ID
位置: 程序包 com.omniprimeinc.commonservice.idgen.redis.model, ID$$JProtoBufClass.java:24: 错误: 找不到符号
public com.omniprimeinc.commonservice.idgen.redis.model.ID decode(byte[] bb) throws IOException {
^
符号: 类 ID
位置: 程序包 com.omniprimeinc.commonservice.idgen.redis.model, ID$$JProtoBufClass.java:47: 错误: 找不到符号
public int size(com.omniprimeinc.commonservice.idgen.redis.model.ID t) throws IOException {
^
符号: 类 ID
位置: 程序包 com.omniprimeinc.commonservice.idgen.redis.model, ID$$JProtoBufClass.java:57: 错误: 找不到符号
public void writeTo(com.omniprimeinc.commonservice.idgen.redis.model.ID t, CodedOutputStream output) throws IOException {
^
符号: 类 ID
位置: 程序包 com.omniprimeinc.commonservice.idgen.redis.model, ID$$JProtoBufClass.java:57: 错误: 找不到符号
public void writeTo(com.omniprimeinc.commonservice.idgen.redis.model.ID t, CodedOutputStream output) throws IOException {
^
符号: 类 CodedOutputStream
位置: 类 com.omniprimeinc.commonservice.idgen.redis.model.ID$$JProtoBufClass, ID$$JProtoBufClass.java:64: 错误: 找不到符号
public com.omniprimeinc.commonservice.idgen.redis.model.ID readFrom(CodedInputStream input) throws IOException {
^
符号: 类 CodedInputStream
位置: 类 com.omniprimeinc.commonservice.idgen.redis.model.ID$$JProtoBufClass, ID$$JProtoBufClass.java:64: 错误: 找不到符号
public com.omniprimeinc.commonservice.idgen.redis.model.ID readFrom(CodedInputStream input) throws IOException {
^
符号: 类 ID
位置: 程序包 com.omniprimeinc.commonservice.idgen.redis.model, ID$$JProtoBufClass.java:86: 错误: 程序包com.google.protobuf.Descriptors不存在
public com.google.protobuf.Descriptors.Descriptor getDescriptor() throws IOException {
^]