-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspringboot mvn de
More file actions
291 lines (267 loc) · 12.9 KB
/
springboot mvn de
File metadata and controls
291 lines (267 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
SegmentFault
首页问答专栏讲堂圈子 发现
搜索问题或关键字
立即登录免费注册
热门标签
全部javascriptphppythonjavamysqliosandroidnode.jshtml5linuxc++css3gitgolangrubyvimdockermongodb
在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。
问
SpringBoot多Module打包无法找到类
module maven springboot 憧憬Licoy 2017年09月13日提问
1 关注
1 收藏,2k 浏览
问题对人有帮助,内容完整,我也想知道答案0 问题没有实际价值,缺少关键内容,没有改进余地
parent的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.licoy</groupId>
<artifactId>parent</artifactId>
<version>0.1</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
<modules>
<module>../rest</module>
<module>../service</module>
</modules>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.16</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>cn.licoy.rest.RestApplication</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
直接在IDEA里面运行SpringBoot启动类是可以正常访问的,但是使用mvn install打包后,报出如下错误:
2017-09-13 16:47:09.318 ERROR 5292 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[disp
atcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context
with path [] threw exception [Handler dispatch failed; nested exception is java
.lang.NoClassDefFoundError: cn/licoy/service/entity/User] with root cause
java.lang.ClassNotFoundException: cn.licoy.service.entity.User
at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_131]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_131]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(Laun
chedURLClassLoader.java:94) ~[rest-0.1.jar:0.1]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_131]
at cn.licoy.rest.controller.UserController.list(UserController.java:24)
~[classes!/:0.1]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.
0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.
0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:
1.8.0_131]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_131]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvok
e(InvocableHandlerMethod.java:205) ~[spring-web-4.3.10.RELEASE.jar!/:4.3.10.RELE
ASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeF
orRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.10.RELEASE.jar!/:4.3
.10.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocabl
eHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) ~[spring-w
ebmvc-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingH
andlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[sprin
g-webmvc-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingH
andlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-web
mvc-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapt
er.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.10.RELEASE.j
ar!/:4.3.10.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(Dispatch
erServlet.java:967) ~[spring-webmvc-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(Dispatche
rServlet.java:901) ~[spring-webmvc-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(Frame
workServlet.java:970) ~[spring-webmvc-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServl
et.java:861) ~[spring-webmvc-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) ~[tomcat
-embed-core-8.5.16.jar!/:8.5.16]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkSer
vlet.java:846) ~[spring-webmvc-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat
-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:231) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:166) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52
) ~[tomcat-embed-websocket-8.5.16.jar!/:8.5.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:193) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:166) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(
RequestContextFilter.java:99) ~[spring-web-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR
equestFilter.java:107) ~[spring-web-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:193) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:166) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInter
nal(HttpPutFormContentFilter.java:105) ~[spring-web-4.3.10.RELEASE.jar!/:4.3.10.
RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR
equestFilter.java:107) ~[spring-web-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:193) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:166) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInterna
l(HiddenHttpMethodFilter.java:81) ~[spring-web-4.3.10.RELEASE.jar!/:4.3.10.RELEA
SE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR
equestFilter.java:107) ~[spring-web-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:193) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:166) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterIntern
al(CharacterEncodingFilter.java:197) ~[spring-web-4.3.10.RELEASE.jar!/:4.3.10.RE
LEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR
equestFilter.java:107) ~[spring-web-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:193) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:166) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:198) ~[tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:96) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:478) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:140) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:80) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:87) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:342) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java
:799) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLig
ht.java:66) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(Abstract
Protocol.java:868) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpo
int.java:1455) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBas
e.java:49) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na
:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [n
a:1.8.0_131]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskTh
read.java:61) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_131]
其中,Springboot启动包是rest包,当中引用了service包中的User类,在打包之后的rest.jar里面lib目录下有service.jar,但是一访问就找不到类,这是怎么回事?
2017年09月13日提问评论邀请回答编辑
1个回答
答案对人有帮助,有参考价值1 答案没帮助,是错误的答案,答非所问
已采纳
问题找到了,要给被依赖的module的pom.xml中添加
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
2017年09月13日回答评论赞赏编辑
憧憬Licoy
584 声望
撰写答案
撰写答案...
Planets
想在上方展示你的广告?
相似问题
springBoot2.0 gradle 多模块项目打包问题。
1 回答 已解决
Springboot maven run
1 回答
springboot很少资料啊,一定要用maven去做吗?
7 回答
maven搭建的springboot项目中如何集成ueditor,实现文件上传功能?
关于springboot 选用maven-archetype-web的问题?
1 回答
分享扩散:
新浪微博微信TwitterFacebook
在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。
产品
热门问答
热门专栏
热门讲堂
最新活动
圈子
找工作
移动客户端
资源
每周精选
用户排行榜
徽章
帮助中心
声望与权限
社区服务中心
开发手册
商务
人才服务
企业培训
活动策划
广告投放
区块链解决方案
合作联系
关于
关于我们
加入我们
联系我们
关注
产品技术日志
社区运营日志
市场运营日志
团队日志
社区访谈
微信 新浪微博 Github Twitter
条款
服务条款
内容许可
扫一扫下载 App
Copyright © 2011-2018 SegmentFault. 当前呈现版本 17.06.16
浙ICP备 15005796号-2 浙公网安备 33010602002000号 杭州堆栈科技有限公司版权所有
CDN 存储服务由 又拍云 赞助提供