话说昨天好好的普通Maven构建项目踩坑完后,今天继续。
之前看《Spring in action》第三版和第四版时发现,第三版是基于xml配置,第四版用了注解。不过书讲的感觉好复杂。我就想跑个简单的例子运行一下。
然后找到这个。http://o7planning.org/web/fe/default/en/document/8108/spring-mvc-tutorial-for-beginners
创建时用了maven的archetype。会发现虽然eclipse没有帮你创建java目录,自己在main文件夹下创建java文件夹后,刷新并没有出现这样的目录结构。我的工程里面还是仅仅只有src/main/resources

接下来我就蛋疼了,没有这个目录,我无法创建package。
此时spring的 <context:component-scan base-package="" /> 根本就无法扫描。
然后尝试不用archetype,虽然有了上面那种目录结构,最后build用tomcat跑起来的时候确实一片空白。
这种坑真的是纠结死人。
纠结到头之后只好换种思路,看看别人是怎么在Eclipse中使用Maven的archetype的。
最后eclipse集成maven3后,创建java项目详细图解看到了问题所在。
原因是new Source Folder了,然后我直接new了个src/main/java
如果提示已经存在还有另外一种方法:在resources直接new folder。

再创建mymvc这个package。
组件扫描, <context:component-scan base-package="mymvc" />
最后成功使用了SpringMVC进行跳转。
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
最近提交(Master分支:1 个月前 )
6e30ae66
The previous implementation cached field accessibility state globally,
which could cause issues when the same field is accessed from different
contexts or security managers. This was particularly problematic in
plugin unit tests where fields would remain accessible after being set.
The fix ensures that field accessibility is properly restored to its
original state after setting field values, preventing accessibility
state from leaking between different bean instances.
Added unit tests to verify:
- Field accessibility is restored after setting values
- Multiple field accesses don't leak accessibility state
- The fix works correctly across different bean instances
This resolves the issue reported on the dev list regarding compiler
plugin unit test failures related to field accessibility.
22 小时前
001c86bb
Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.5.20 to 1.5.21.
- [Release notes](https://github.com/qos-ch/logback/releases)
- [Commits](https://github.com/qos-ch/logback/compare/v_1.5.20...v_1.5.21)
---
updated-dependencies:
- dependency-name: ch.qos.logback:logback-classic
dependency-version: 1.5.21
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 2 天前
所有评论(0)