2012-03-08 8 views
1

春にMavenでWebプロジェクトを行っている人は誰ですか? なぜ私は自分のプロジェクトを動かすことができないのか分からないので、それを理解するためのプロジェクトが必要です。 spring mvcを使用した簡単なログイン/ログアウトのプロジェクトです。maven with spring mvc

戦車

私は、サーバー上でプロジェクトを実行するとき、私はHTTP 404を取得し、私が間違っている可能性がありますかわかりません。

web.xmlの

<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns /persistence/persistence_2_0.xsd" 
     version="2.0"> 
    <persistence-unit name="bokingguard" transaction-type="RESOURCE_LOCAL"> 
     <provider>org.hibernate.ejb.HibernatePersistence</provider> 
     <!-- Entities --> 
     <properties> 
      <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> 
      <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/book"/> 
      <property name="hibernate.connection.username" value=""/> 
      <property name="hibernate.connection.password" value="" /> 
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> 
      <property name="hibernate.hbm2ddl.auto" value="update"/> 
      <property name="show_sql" value="true" /> 
     </properties>  
    </persistence-unit> 
</persistence> 

春-servlet.xml

<?xml version="1.0" encoding="windows-1252"?> 
    <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" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop" 
xmlns:tx="http://www.springframework.org/schema/tx" 
xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd 
    http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> 

<!-- Use @Component annotations for bean definitions --> 
<context:component-scan base-package="se.guard.domain" /> 
<context:component-scan base-package="se.guard.repository" /> 
<context:component-scan base-package="se.guard.service" /> 
<context:component-scan base-package="se.guard.controller" /> 

<!-- Use @Controller annotations for MVC controller definitions --> 
<mvc:annotation-driven /> 

<!-- Add JPA support --> 
<bean id="emf" 
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
    <property name="loadTimeWeaver"> 
     <bean 
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" /> 
    </property> 
</bean> 
<!-- Add Transaction support --> 
<bean id="myTxManager" class="org.springframework.orm.jpa.JpaTransactionManager"> 
    <property name="entityManagerFactory" ref="emf" /> 
</bean> 
<!-- Use @Transaction annotations for managing transactions --> 
<tx:annotation-driven transaction-manager="myTxManager" /> 
<!-- View resolver --> 
<bean 
    class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
    <property name="prefix" value="/WEB-INF/" /> 
    <property name="suffix" value=".jsp" /> 
</bean> 
</beans> 

+1

あなたが直面しているエラーを投稿して、より良いお手伝いをする必要があります。これは非常に曖昧な質問です。 – bvulaj

+0

どのバージョンの春ですか?ログイン/ログアウトは、春のセキュリティが必要であることを意味します。 – Raghuram

+0

とspring-service.xml user1067665

答えて

1

利用スプリング: たぶん何かが私のxml-ファイルのSOMと間違っていますPetClinicまたはMaven archetypesをSpring MVCで動作するアプリケーション

0

Spring Rooを使用すると、mavenを使用し、自動的に適切な依存関係が設定されたSpring推奨プロジェクト構造を生成できます。 これを使用して、ログイン時にSpring Securityと統合することもできます。&ログアウト。

1

web.xmlに春の設定が表示されません。春の設定を追加することを忘れないでください。ファイル>新規>プロジェクト>のSpringSourceツールスイート>春テンプレートプロジェクト:例えば:

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value> 
</context-param> 
... 
<servlet> 
    <servlet-name>YourServlet</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    <init-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>WEB-INF/spring/webmvc-config.xml</param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup> 
</servlet> 

<servlet-mapping> 
    <servlet-name>YourServlet</servlet-name> 
    <url-pattern>/</url-pattern> 
</servlet-mapping> 
... 

はところで、STS(SpringSourceのツールスイート)で、あなたは面白いオプションがあります。その後、Spring MVCプロジェクトを選択すると、MavenとSpring MVCを使用したHelloWorldプロジェクトが与えられます。

また、Samarthが指摘しているように、Spring RooはSpringアプリケーションのブートストラップのためにクールです。