English 中文(简体)
将简单的 Java 应用程序转换为动态网络工程
原标题:Convert simple Java application to Dynamic web project

我试图将一个简单的项目转换成一个动态的网络项目。

我正在使用WebSphere 应用程序服务器, 我想在这里运行我的简单应用程序 。

当我右键点击并作为一个 Java 应用程序运行时, 它运行很顺利 。 我在哪里进行修改才能在 WebSphere 应用程序服务器上运行?

<强 > 抽样项目

--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

< 强/强> AP.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();
    }
}

(b) [hello World.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>

< 加强 > 应用测试.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 );
    }
}
问题回答

既然您已经使用马文, 最容易的可能是配置 in http://maven.apache.org/plugins/maven-eclipse-plugin/"rel="nofolf">>maven-eclipse-plugin 。 并运行以下关于这个项目的操作 :

mvn eclipse:eclipse

另一个选项是安装"http://markedplace.eclipse.org/content/maven-commission-eclipse-wtp" rel=“不随从”





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签