2012-05-27 4 views
0

Désolé d'avoir posé cette question stupide, je me suis cassé la tête mais je ne savais toujours pas comment convertir un simple projet en projet web dynamique. J'utilise WebSphere Application Server, où je veux exécuter ma simple application.Convertir une application Java simple en projet Web dynamique

Voici la structure du projet de l'application, quand je clique droit et exécuter en tant qu'application java, il fonctionne bien. Où puis-je apporter des modifications afin de pouvoir l'exécuter sur WebSphere Application Server?

sampleProject

--src 
| |--main 
| | |--java 
| |  --com 
| |  --mykong 
| |   --core 
| |   --App.java 
| |   --HelloWorld.java  
| | 
| | |--resouces 
| |  --SpringBeans.xml 
| | 
| |--test 
|  |--java 
|   --com 
|   --mykong 
|    --core 
|    --AppTest.java 
| 
|--target 
|--.classpath 
|--.project 
|--.pom.xml 

App.java

package com.mkyong.core; 

import org.springframework.context.ApplicationContext; 
import org.springframework.context.support.ClassPathXmlApplicationContext; 

public class App { 
    public static void main(String[] args) { 
     ApplicationContext context = new ClassPathXmlApplicationContext(
       "SpringBeans.xml"); 

     HelloWorld obj = (HelloWorld) context.getBean("helloBean"); 
     obj.printHello(); 
    } 
} 

HelloWorld.java

package com.mkyong.core; 

/** 
* Spring bean 
* 
*/ 
public class HelloWorld { 
    private String name; 

    public void setName(String name) { 
     this.name = name; 
    } 

    public void printHello() { 
     System.out.println("Spring 3 : Hello ! " + name); 
    } 
} 

SpringBeans.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.mkyong.core.HelloWorld"> 
     <property name="name" value="Mkyong" /> 
    </bean> 

</beans> 

AppTest.java

package com.mkyong.core; 

import junit.framework.Test; 
import junit.framework.TestCase; 
import junit.framework.TestSuite; 

/** 
* Unit test for simple App. 
*/ 
public class AppTest 
    extends TestCase 
{ 
    /** 
    * Create the test case 
    * 
    * @param testName name of the test case 
    */ 
    public AppTest(String testName) 
    { 
     super(testName); 
    } 

    /** 
    * @return the suite of tests being tested 
    */ 
    public static Test suite() 
    { 
     return new TestSuite(AppTest.class); 
    } 

    /** 
    * Rigourous Test :-) 
    */ 
    public void testApp() 
    { 
     assertTrue(true); 
    } 
} 

Merci pour votre aide .....

+0

Utilisez-vous le plugin m2e ou le plugin maven-eclipse pour créer le projet Eclipse? –

+0

Je n'utilise aucun plugin, j'ai téléchargé cet exemple sur le site mykong. – Namita

+0

J'ai ajouté manuellement des jarres de dépendances dans classpath. – Namita

Répondre

Questions connexes