1、创建Maven Project
2、点击下一步,create a simple project ……不要勾选
3、点击下一步,选择webapp
4、点击下一步,输入Group Id和Artifact Id
5、点击finish,完成创建,文档结构图如下
6、在main文件夹下创建java文件夹,用于存储java源代码,打开项目属性-Java Build Path-Source-Add Folder,选中java文件夹
7、编辑pom.xml 加入Spring的依赖
<properties> <spring.version>3.0.5.RELEASE</spring.version> </properties> <dependencies> <!-- Spring3 dependencies --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> </dependencies>
8、创建HelloWorld类和sayHello方法
package com.yimiw.spring3.hello; public class HelloWorld { public void sayHello(){ System.out.println("Hello World"); } }
9、resource目录下创建spring-bean.xml文件
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="helloBean" class="com.yimiw.spring3.hello.HelloWorld"> </bean> </beans>
10、创建用于测试的Test类
package com.yimiw.spring3.hello; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Test { public static void main(String[] args) { ApplicationContext context= new ClassPathXmlApplicationContext("spring-bean.xml"); HelloWorld obj=(HelloWorld)context.getBean("helloBean"); obj.sayHello(); } }
11,、运行Test类,输出Hello World
相关推荐
maven下的spring mvc 【hello world】案例
Maven+SpringMVC的入门级HelloWorld实例,简单了解Maven和SpringMVC整合
spring5.0的mvc项目实例,HelloWorld实例,基于eclipse oxygen jee 的maven project
NULL 博文链接:https://jiaozhiguang-126-com.iteye.com/blog/1843178
通过maven来配置spring mvc,开发工具为IntelliJ IDEA,服务器为tomcat,页面主要有一个hello world 页面和一个test页面
是不是好东西你们去鉴定,SpringMVC + Spring + ibatis 可以配置多数据源,这个Demo 扩展性极强,就看你们自己如何发挥。
Maven-Spring 3 MVC Hello World 使用Maven构建工具的Spring 3 MVC + JSP视图+ XML配置模板。 ### 1。 使用的技术 Maven的3 春天3.2.13。发布 JSTL 1.2 登入1.1.3 Boostrap 3 ### 2。 在本地运行该项目 $ git ...
spring+maven+mybatis+junit+mysql+idea-helloworld源码
最简单的Spring MVC 实现hello world , maven 实现 没有集成 mybatis。避免了搭建框架的配置时期,实现最基本的功能
SpringMVC 3.0 HelloWorld 源码 (Maven)
spring-mvc-helloworld 可以通过jetty启动,访问 http://localhost:8010/spring-mvc-helloworld/hello/world
webservice地址 http://localhost:8080/springCxf/HelloWorld?wsdl
Spring3.1.2+Mybatis3.1.1+Restlet2.0.1框架HelloWorld实例(Maven) maven package生成后打包war部署到tomacat测试: http://localhost:8080/oa/rest/hello 数据库为postgresql 9.2,单元测试中有mybatis的数据库...
Eclipse中Maven+Spring3.2.8+SpringMVC HelloWorld项目-附件资源
Spring Boot 学习示例 Spring Boot 2.0 Mysql 5.6 ...spring-boot-helloworld:Spring Boot 3.0 Hello World Test 单元测试示例 spring-boot-scheduler:Spring Boot 3.0 定时任务 scheduler 使用示例 .....
网上的SpringBoot项目按照教程生成以后,导入会报错,修改后正常运行