Maven update在eclipse中更改项目的上下文根

6ojccjat  于 2024-01-06  发布在  Maven
关注(0)|答案(2)|浏览(343)

在Spring应用程序上工作,并使用Maven 3作为构建工具。我的应用程序在Windows机器上的Eclipse neon 中正常工作。
现在我在Mac系统上使用Oxygen。我的应用程序需要一个特定的上下文根,即/app
当我通过更改.settings/org.eclipse.wst.common.component文件或Web项目设置属性来设置context-root后更新(maven update)它时,它会将context-root再次恢复为app
这里是我的pom.xml

  1. <?xml version="1.0" encoding="UTF-8"?>

字符串
http://maven.apache.org/maven-v4_0_0.xsd“> 4.0.0 abc app war 1.0

  1. <properties>
  2. <spring.security>3.1.3.RELEASE</spring.security>
  3. <spring-social>1.1.0.M1</spring-social>
  4. <hibernate.version>3.6.3.Final</hibernate.version>
  5. <spring.version>3.2.0.RELEASE</spring.version>
  6. <commons-dbcp.version>1.4</commons-dbcp.version>
  7. <maven-compiler-plugin.version>2.3.1</maven-compiler-plugin.version>
  8. <maven-resources-plugin.version>2.4.3</maven-resources-plugin.version>
  9. <maven-war-plugin.version>2.1.1</maven-war-plugin.version>
  10. <tomcat-maven-plugin.version>1.1</tomcat-maven-plugin.version>
  11. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  12. </properties>
  13. <repositories>
  14. <repository>
  15. <id>spring-milestone</id>
  16. <name>Spring Milestone Repository</name>
  17. <url>https://repo.spring.io/milestone</url>
  18. </repository>
  19. <repository>
  20. <id>java.net2</id>
  21. <name>Java.net</name>
  22. <url>https://oss.sonatype.org/content/repositories/java.net2</url>
  23. </repository>
  24. <repository>
  25. <id>spring-repo</id>
  26. <url>http://maven.springframework.org</url>
  27. </repository>
  28. <repository>
  29. <id>org.springframework.maven.release</id>
  30. <name>Spring Maven Release Repository</name>
  31. <url>http://maven.springframework.org/release</url>
  32. </repository>
  33. <repository>
  34. <id>org.springframework.maven.milestone</id>
  35. <name>Spring Maven Milestone Repository</name>
  36. <url>http://maven.springframework.org/milestone</url>
  37. </repository>
  38. <repository>
  39. <id>spring-snap</id>
  40. <url>http://maven.springframework.org/snapshot/</url>
  41. </repository>
  42. </repositories>
  43. <dependencies>
  44. <!-- JSON SPRING DEPENDENCIES -->
  45. <dependency>
  46. <groupId>org.codehaus.jackson</groupId>
  47. <artifactId>jackson-mapper-asl</artifactId>
  48. <version>1.9.3</version>
  49. </dependency>
  50. <dependency>
  51. <groupId>com.fasterxml.jackson.core</groupId>
  52. <artifactId>jackson-annotations</artifactId>
  53. <version>2.4.1</version>
  54. </dependency>
  55. <dependency>
  56. <groupId>com.fasterxml.jackson.core</groupId>
  57. <artifactId>jackson-core</artifactId>
  58. <version>2.4.1</version>
  59. </dependency>
  60. <dependency>
  61. <groupId>com.fasterxml.jackson.core</groupId>
  62. <artifactId>jackson-databind</artifactId>
  63. <version>2.4.1</version>
  64. </dependency>
  65. <dependency>
  66. <groupId>cglib</groupId>
  67. <artifactId>cglib-nodep</artifactId>
  68. <version>2.2</version>
  69. </dependency>
  70. <!-- APACHE COMMONS DEPENDENCIES -->
  71. <dependency>
  72. <groupId>org.apache.commons</groupId>
  73. <artifactId>commons-lang3</artifactId>
  74. <version>3.1</version>
  75. </dependency>
  76. <dependency>
  77. <groupId>commons-validator</groupId>
  78. <artifactId>commons-validator</artifactId>
  79. <version>1.3.1</version>
  80. </dependency>
  81. <dependency>
  82. <groupId>oro</groupId>
  83. <artifactId>oro</artifactId>
  84. <version>2.0.8</version>
  85. </dependency>
  86. <dependency>
  87. <groupId>org.apache.velocity</groupId>
  88. <artifactId>velocity</artifactId>
  89. <version>1.7</version>
  90. </dependency>
  91. <!-- SPRING DEPENDENCIES -->
  92. <dependency>
  93. <groupId>org.springframework</groupId>
  94. <artifactId>spring-orm</artifactId>
  95. <version>3.1.2.RELEASE</version>
  96. </dependency>
  97. <dependency>
  98. <groupId>org.springframework.data</groupId>
  99. <artifactId>spring-data-jpa</artifactId>
  100. <version>1.2.0.RELEASE</version>
  101. </dependency>
  102. <dependency>
  103. <groupId>org.springframework</groupId>
  104. <artifactId>spring-core</artifactId>
  105. <version>${spring.version}</version>
  106. </dependency>
  107. <dependency>
  108. <groupId>org.springframework</groupId>
  109. <artifactId>spring-context</artifactId>
  110. <version>${spring.version}</version>
  111. </dependency>
  112. <dependency>
  113. <groupId>org.springframework</groupId>
  114. <artifactId>spring-beans</artifactId>
  115. <version>${spring.version}</version>
  116. </dependency>
  117. <dependency>
  118. <groupId>org.springframework</groupId>
  119. <artifactId>spring-aop</artifactId>
  120. <version>${spring.version}</version>
  121. </dependency>
  122. <dependency>
  123. <groupId>org.springframework</groupId>
  124. <artifactId>spring-jdbc</artifactId>
  125. <version>${spring.version}</version>
  126. </dependency>
  127. <dependency>
  128. <groupId>org.springframework</groupId>
  129. <artifactId>spring-oxm</artifactId>
  130. <version>${spring.version}</version>
  131. </dependency>
  132. <dependency>
  133. <groupId>org.springframework</groupId>
  134. <artifactId>spring-aspects</artifactId>
  135. <version>${spring.version}</version>
  136. </dependency>
  137. <dependency>
  138. <groupId>org.aspectj</groupId>
  139. <artifactId>aspectjrt</artifactId>
  140. <version>1.6.10</version>
  141. </dependency>
  142. <dependency>
  143. <groupId>org.aspectj</groupId>
  144. <artifactId>aspectjweaver</artifactId>
  145. <version>1.6.10</version>
  146. </dependency>
  147. <dependency>
  148. <groupId>org.springframework</groupId>
  149. <artifactId>spring-webmvc</artifactId>
  150. <version>${spring.version}</version>
  151. </dependency>
  152. <dependency>
  153. <groupId>org.springframework</groupId>
  154. <artifactId>spring-test</artifactId>
  155. <version>${spring.version}</version>
  156. <scope>test</scope>
  157. </dependency>
  158. <dependency>
  159. <groupId>org.springframework.security</groupId>
  160. <artifactId>spring-security-acl</artifactId>
  161. <version>${spring.security}</version>
  162. </dependency>
  163. <dependency>
  164. <groupId>org.springframework.security</groupId>
  165. <artifactId>spring-security-config</artifactId>
  166. <version>${spring.security}</version>
  167. </dependency>
  168. <dependency>
  169. <groupId>org.springframework.security</groupId>
  170. <artifactId>spring-security-web</artifactId>
  171. <version>${spring.security}</version>
  172. </dependency>
  173. <dependency>
  174. <groupId>org.springframework.security</groupId>
  175. <artifactId>spring-security-core</artifactId>
  176. <version>${spring.security}</version>
  177. </dependency>
  178. <dependency>
  179. <groupId>org.springframework.security</groupId>
  180. <artifactId>spring-security-crypto</artifactId>
  181. <version>${spring.security}</version>
  182. </dependency>
  183. <dependency>
  184. <groupId>org.springframework.security</groupId>
  185. <artifactId>spring-security-taglibs</artifactId>
  186. <version>${spring.security}</version>
  187. </dependency>
  188. <dependency>
  189. <groupId>org.thymeleaf</groupId>
  190. <artifactId>thymeleaf-spring3</artifactId>
  191. <version>2.0.14</version>
  192. </dependency>
  193. <dependency>
  194. <groupId>c3p0</groupId>
  195. <artifactId>c3p0</artifactId>
  196. <version>0.9.1.2</version>
  197. </dependency>
  198. <dependency>
  199. <groupId>javax.activation</groupId>
  200. <artifactId>activation</artifactId>
  201. <version>1.1</version>
  202. </dependency>
  203. <dependency>
  204. <groupId>javax.mail</groupId>
  205. <artifactId>mail</artifactId>
  206. <version>1.4.2</version>
  207. </dependency>
  208. <dependency>
  209. <groupId>com.sun.mail</groupId>
  210. <artifactId>javax.mail</artifactId>
  211. <version>1.5.5</version>
  212. </dependency>
  213. <!--Misc dependencies -->
  214. <dependency>
  215. <groupId>javax.servlet</groupId>
  216. <artifactId>servlet-api</artifactId>
  217. <version>2.5</version>
  218. <scope>provided</scope>
  219. </dependency>
  220. <dependency>
  221. <groupId>javax.servlet</groupId>
  222. <artifactId>jstl</artifactId>
  223. <version>1.1.2</version>
  224. </dependency>
  225. <dependency>
  226. <groupId>junit</groupId>
  227. <artifactId>junit</artifactId>
  228. <version>4.8.1</version>
  229. <scope>test</scope>
  230. </dependency>
  231. <!-- HIBERNATE DEPENDENCIES -->
  232. <dependency>
  233. <groupId>org.hibernate</groupId>
  234. <artifactId>hibernate-core</artifactId>
  235. <version>${hibernate.version}</version>
  236. <type>jar</type>
  237. </dependency>
  238. <dependency>
  239. <groupId>org.hibernate</groupId>
  240. <artifactId>hibernate-entitymanager</artifactId>
  241. <version>${hibernate.version}</version>
  242. <type>jar</type>
  243. </dependency>
  244. <dependency>
  245. <groupId>org.hibernate.java-persistence</groupId>
  246. <artifactId>jpa-api</artifactId>
  247. <version>2.0-cr-1</version>
  248. </dependency>
  249. <dependency>
  250. <groupId>org.hibernate.javax.persistence</groupId>
  251. <artifactId>hibernate-jpa-2.0-api</artifactId>
  252. <version>1.0.0.Final</version>
  253. </dependency>
  254. <dependency>
  255. <groupId>commons-dbcp</groupId>
  256. <artifactId>commons-dbcp</artifactId>
  257. <version>${commons-dbcp.version}</version>
  258. <type>jar</type>
  259. </dependency>
  260. <!-- LOGGING DEPENDENCIES - LOG4J -->
  261. <dependency>
  262. <groupId>org.slf4j</groupId>
  263. <artifactId>slf4j-log4j12</artifactId>
  264. <version>1.6.1</version>
  265. <type>jar</type>
  266. </dependency>
  267. <dependency>
  268. <groupId>log4j</groupId>
  269. <artifactId>log4j</artifactId>
  270. <version>1.2.14</version>
  271. <type>jar</type>
  272. </dependency>
  273. <dependency>
  274. <groupId>mysql</groupId>
  275. <artifactId>mysql-connector-java</artifactId>
  276. <version>5.1.6</version>
  277. <type>jar</type>
  278. </dependency>
  279. <dependency>
  280. <groupId>javax.mail</groupId>
  281. <artifactId>javax.mail-api</artifactId>
  282. <version>1.4.4</version>
  283. </dependency>
  284. <dependency>
  285. <groupId>taglibs</groupId>
  286. <artifactId>standard</artifactId>
  287. <version>1.1.2</version>
  288. <type>jar</type>
  289. </dependency>
  290. <dependency>
  291. <groupId>commons-io</groupId>
  292. <artifactId>commons-io</artifactId>
  293. <version>1.3.2</version>
  294. </dependency>
  295. <dependency>
  296. <groupId>commons-fileupload</groupId>
  297. <artifactId>commons-fileupload</artifactId>
  298. <version>1.2</version>
  299. </dependency>
  300. <dependency>
  301. <groupId>org.springframework.social</groupId>
  302. <artifactId>spring-social-web</artifactId>
  303. <version>${spring-social}</version>
  304. </dependency>
  305. <dependency>
  306. <groupId>org.springframework.social</groupId>
  307. <artifactId>spring-social-config</artifactId>
  308. <version>${spring-social}</version>
  309. </dependency>
  310. <dependency>
  311. <groupId>org.springframework.social</groupId>
  312. <artifactId>spring-social-twitter</artifactId>
  313. <version>${spring-social}</version>
  314. </dependency>
  315. <dependency>
  316. <groupId>org.springframework.social</groupId>
  317. <artifactId>spring-social-facebook</artifactId>
  318. <version>3.0.0.M1</version>
  319. </dependency>
  320. <dependency>
  321. <groupId>org.springframework.social</groupId>
  322. <artifactId>spring-social-google</artifactId>
  323. <version>1.0.0.RELEASE</version>
  324. </dependency>
  325. <dependency>
  326. <groupId>org.json</groupId>
  327. <artifactId>json</artifactId>
  328. <version>20160212</version>
  329. </dependency>
  330. <dependency>
  331. <groupId>com.mysema.querydsl</groupId>
  332. <artifactId>querydsl-jpa</artifactId>
  333. <version>2.8.0</version>
  334. </dependency>
  335. <dependency>
  336. <groupId>commons-httpclient</groupId>
  337. <artifactId>commons-httpclient</artifactId>
  338. <version>3.1</version>
  339. </dependency>
  340. <dependency>
  341. <groupId>commons-collections</groupId>
  342. <artifactId>commons-collections</artifactId>
  343. <version>3.1</version>
  344. </dependency>
  345. <dependency>
  346. <groupId>commons-codec</groupId>
  347. <artifactId>commons-codec</artifactId>
  348. <version>1.6</version>
  349. </dependency>
  350. <dependency>
  351. <groupId>commons-lang</groupId>
  352. <artifactId>commons-lang</artifactId>
  353. <version>2.5</version>
  354. </dependency>
  355. <dependency>
  356. <groupId>commons-logging</groupId>
  357. <artifactId>commons-logging</artifactId>
  358. <version>1.1.1</version>
  359. </dependency>
  360. <dependency>
  361. <groupId>org.apache.poi</groupId>
  362. <artifactId>poi-scratchpad</artifactId>
  363. <version>3.0.1-FINAL</version>
  364. </dependency>
  365. <dependency>
  366. <groupId>org.apache.poi</groupId>
  367. <artifactId>poi-ooxml</artifactId>
  368. <version>3.7-beta3</version>
  369. </dependency>
  370. <dependency>
  371. <groupId>com.itextpdf</groupId>
  372. <artifactId>itextpdf</artifactId>
  373. <version>5.0.6</version>
  374. </dependency>
  375. <dependency>
  376. <groupId>org.modelmapper</groupId>
  377. <artifactId>modelmapper</artifactId>
  378. <version>0.7.7</version>
  379. </dependency>
  380. <dependency>
  381. <groupId>org.apache.httpcomponents</groupId>
  382. <artifactId>httpclient</artifactId>
  383. <version>4.4</version>
  384. </dependency>
  385. <dependency>
  386. <groupId>org.joda</groupId>
  387. <artifactId>joda-money</artifactId>
  388. <version>0.12</version>
  389. </dependency>
  390. <dependency>
  391. <groupId>org.springframework.batch</groupId>
  392. <artifactId>spring-batch-core</artifactId>
  393. <version>3.0.4.RELEASE</version>
  394. </dependency>
  395. </dependencies>
  396. <build>
  397. <finalName>app</finalName>
  398. <directory>target</directory>
  399. <outputDirectory>target/classes</outputDirectory>
  400. <testOutputDirectory>target/test-classes</testOutputDirectory>
  401. <sourceDirectory>src</sourceDirectory>
  402. <plugins>
  403. <plugin>
  404. <groupId>org.apache.maven.plugins</groupId>
  405. <artifactId>maven-compiler-plugin</artifactId>
  406. <version>${maven-compiler-plugin.version}</version>
  407. <configuration>
  408. <source>1.7</source>
  409. <target>1.7</target>
  410. <optimize>true</optimize>
  411. <debug>true</debug>
  412. <wtpContextName>/app</wtpContextName>
  413. </configuration>
  414. </plugin>
  415. <plugin>
  416. <groupId>org.apache.maven.plugins</groupId>
  417. <artifactId>maven-resources-plugin</artifactId>
  418. <version>${maven-resources-plugin.version}</version>
  419. <configuration>
  420. <encoding>${project.build.sourceEncoding}</encoding>
  421. </configuration>
  422. </plugin>
  423. <plugin>
  424. <artifactId>maven-war-plugin</artifactId>
  425. <version>${maven-war-plugin.version}</version>
  426. <configuration>
  427. <warSourceDirectory>WebContent</warSourceDirectory>
  428. <webXml>WebContent/WEB-INF/web.xml</webXml>
  429. </configuration>
  430. </plugin>
  431. </plugins>
  432. </build>


有没有其他的方法来改变上下文根或任何想法为什么maven更新不断变化的上下文根?

ru9i0ody

ru9i0ody1#

参见M2 E-WTP常见问题解答。它说指定

  1. <properties>
  2. <m2eclipse.wtp.contextRoot>/app</m2eclipse.wtp.contextRoot>
  3. ...
  4. </properties>

字符串
至少在Eclispe 2018-12(4.10.0)和M2 E 1.10.0上对我来说是这样的
this这样的旧解决方案似乎不起作用。

gpfsuwkq

gpfsuwkq2#

当您使用maven项目时,IDE通常会从POM文件导入设置,因此您应该更新POM,而不是更改IDE设置,并且当您更新时它将自动导入。
在您的情况下,请尝试在POM中更改wtpContextNamefinalName并更新/重新导入。

相关问题