Myeclipse利用maven构建sping web项目

新建Maven Project

选择webapp快速构架,这样就生成项目了

可以右键项目Properties更改编码设置

在这里可以更改java和Dynamic Web Module

设置Assembly

如果只有src/main/resources的话需要手动三个source folder

src/main/java     src/test/java    src/test/resources

在build path里面更改output folder

pom.xml设置

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.xiao.xiong</groupId>
  <artifactId>cly</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>cly Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.9</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.0.5.RELEASE</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>cly</finalName>
  </build>
</project>

beans.xml

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
       
       <bean id="car1" class="com.baobaotao.Car"
           p:brand="红旗CA72"
           p:color="黑色"
           p:maxSpeed="200"/>
       
</beans>
public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
        Car car = (Car) ctx.getBean("car1");
        System.out.println(car);
    }

 

posted on 2015-04-06 19:27  颓废的悠然  阅读(201)  评论(0编辑  收藏  举报

导航