Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对SpringBoot项目进行mock时正常业务会报错 #13

Open
wangbiaogg-git opened this issue Mar 14, 2024 · 0 comments
Open

对SpringBoot项目进行mock时正常业务会报错 #13

wangbiaogg-git opened this issue Mar 14, 2024 · 0 comments

Comments

@wangbiaogg-git
Copy link

wangbiaogg-git commented Mar 14, 2024

这个是agent日志:

2024-03-14 17:28:14 [Attach Listener] WARN c.c.foxmock.agent.FoxMockAgent -org.apache.ibatis.executor.BaseExecutor ClassNotFoundException 2024-03-14 17:28:14 [Attach Listener] WARN c.c.foxmock.agent.FoxMockAgent -org.apache.ibatis.executor.CachingExecutor ClassNotFoundException

这个是业务应用(SpringBoot jar包项目)日志:
Caused by: java.lang.NoClassDefFoundError: org/apache/dubbo/rpc/Result at org.apache.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java) at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:82) at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$CallbackRegistrationInvoker.invoke(ProtocolFilterWrapper.java:157) at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56) at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:82) ... 93 more Caused by: java.lang.ClassNotFoundException: org.apache.dubbo.rpc.Result at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... 98 more

备注:
SpringBoot项目打包用的spring-boot-maven-plugin时,存在以上问题

<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.xxx.Main</mainClass> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin>

如果采用shade-plugin则可正常mock:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.1.2.RELEASE</version> </dependency> <dependency> <groupId>com.github.edwgiz</groupId> <artifactId>maven-shade-plugin.log4j2-cachefile-transformer</artifactId> <version>2.6.1</version> </dependency> </dependencies> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration combine.self="override"> <createDependencyReducedPom>false</createDependencyReducedPom> <shadedArtifactAttached>false</shadedArtifactAttached> <finalName>${project.artifactId}-${project.version}</finalName> <filters> <filter> <artifact>*</artifact> <excludes> <exclude>log4j.properties</exclude> <exclude>log4j-test.properties</exclude> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> <artifactSet> </artifactSet> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>reference.conf</resource> <resource>META-INF/spring.handlers</resource> <resource>META-INF/spring.schemas</resource> </transformer> <transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer"> <resource>META-INF/spring.factories</resource> </transformer> <!-- The service transformer is needed to merge META-INF/services files --> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer"/> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.xxx.Main</mainClass> </transformer> <transformer implementation="com.github.edwgiz.mavenShadePlugin.log4j2CacheTransformer.PluginsCacheFileTransformer" /> </transformers> </configuration> </execution> <execution> <id>shade</id> <phase>none</phase> </execution> </executions> </plugin>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant