แสดงบทความที่มีป้ายกำกับ maven แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ maven แสดงบทความทั้งหมด

วันเสาร์ที่ 16 กรกฎาคม พ.ศ. 2559

การ Config SpringBoot ให้ใช้งานแบบมี web.xml

การ Config แบบนี้จะต้องย้ายพวก filter ออกมาจาก annotation แล้วมา config บน web.xml ให้หมดด้วยครับ ไม่งั้นจะใช้งานไม่ได้ ใน web.xml ผมมีตัวอย่างของการ Config CXF ด้วย ว่าต้องย้ายมาไว้บน web.xml ด้วยไม่งั้นใช้งานไม่ได้
<context-param>
 <param-name>contextConfigLocation</param-name>
 <param-value>xxx.Application</param-value>
</context-param>

<listener>
 <listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener</listener-class>
</listener>

<servlet>
 <servlet-name>spring</servlet-name>
 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
 <init-param>
  <param-name>contextAttribute</param-name>
  <param-value>org.springframework.web.context.WebApplicationContext.ROOT
  </param-value>
 </init-param>
 <load-on-startup>1</load-on-startup>
</servlet>

<!-- Servlet Mapping for CXFServlet -->
<servlet>
 <servlet-name>CXFServlet</servlet-name>
 <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet>

<servlet-mapping>
 <servlet-name>CXFServlet</servlet-name>
 <url-pattern>/soap-api/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
 <servlet-name>spring</servlet-name>
 <url-pattern>/*</url-pattern>
</servlet-mapping>
- จะเห็นว่าใช้ org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener ตัวนี้แทนของเดิม
- contextConfigLocation เพื่อไปอ่าน Class ที่ Config ของ  SpringBoot เหมือนกับที่ต้อง config บน start-class ที่ใช้บน maven เพื่อให้มันทำานได้

วันพุธที่ 30 เมษายน พ.ศ. 2557

Config Maven สำหรับ Websphere

เป็นการ Config Eclipse เพิ่มเติมสำหรับ Add Reference Websphere  ครับ
โดยเพิ่ม ข้อมูลตามนี้ แยกตามแต่ละชนิดของ Application (ในส่วน additionalProjectFacets) แล้วใส่เลขเวอร์ชั่นของ Websphere  ลงไป

 <plugin>  
                     <groupId>org.apache.maven.plugins</groupId>  
                     <artifactId>maven-eclipse-plugin</artifactId>  
                     <version>2.9</version>  
                     <configuration>  
                          <wtpversion>2.0</wtpversion>  
                          <additionalProjectFacets>  
                               <jst.ear>6.0</jst.ear>  
                               <com.ibm.websphere.extended.ear>8.0</com.ibm.websphere.extended.ear>  
                               <com.ibm.websphere.coexistence.ear>8.0</com.ibm.websphere.coexistence.ear>  
                          </additionalProjectFacets>  
                     </configuration>  
                </plugin>  

1. Web Project เพิ่ม
     - com.ibm.websphere.extended.web
     - com.ibm.websphere.coexistence.web
2. EJB Project
     - com.ibm.websphere.extended.ejb
3. Enterprise Project
     - com.ibm.websphere.extended.ear
     - com.ibm.websphere.coexistence.ear

วันพุธที่ 2 เมษายน พ.ศ. 2557

Config Maven ให้โหลด Source และ API Docs

ปกติสามารถโหลดได้จาก Command Line ได้เลยครับ หรือจะไป Config บน settings.xml

1. แบบที่ทำผ่าน Command Line ให้เพิ่ม

-DdownloadSources=true -DdownloadJavadocs=true  
 
2. แบบที่เพิ่มใน settings.xml (ให้เพิ่มไฟล์นี้ใน Folder .m2)

<profiles>
     <profile> 
          <id>downloadSources</id>
          <properties> 
               <downloadSources>true</downloadSources>
               <downloadJavadocs>true</downloadJavadocs>
          </properties> 
     </profile> 
</profiles> 
<activeProfiles> 
     <activeProfile>downloadSources</activeProfile> 
</activeProfiles> 


Reference
http://stackoverflow.com/questions/5780758/maven-always-download-sources-and-javadocs

วันอังคารที่ 28 กุมภาพันธ์ พ.ศ. 2555

วันเสาร์ที่ 10 กรกฎาคม พ.ศ. 2553

การสร้าง jax-ws บน Tomcat

ผมเขียนโดยใช้ maven ในการสร้าง Project น่ะครับ และทำให้รันบน Tomcat ถ้าบน Application Server ใช้ Config น้อยกว่านี้น่ะครับ
1. เพิ่ม Config ใน Maven เข้ามาเพื่อ Load Library
<dependency>
<groupid>com.sun.xml.ws</groupid>
<artifactid>jaxws-rt</artifactid>
<version>2.2.1</version>
</dependency>

2. Config Maven ให้ใช้งาน Tomcat ได้ ไม่สอนนะครับ เพราะว่า copy มาใช้งานได้จากเวบอยู่แล้วไม่ยากเท่าไรน่ะครับ
3. ต่อไปมาดูส่วนของ Class ปกติการเขียน jax-ws เราจะใช้ Java Class มาใช้โดยการเพิ่ม annotation เพื่อบอกมันว่าจะใช้งานเป็น Web Service ได้เลยน่ะครับ แต่รันบน Tomcat เราจะต้องมี Config เพิ่มในส่วนของ web.xml

@WebService <-- จะเห็นว่าแค่บอกว่าจะใช้ Web Service ก็จะสามารถทำงานเป็น Web Service ได้เลยน่ะครับ
public class Hello {

public String sayHello(String param) { <-- เป็น Method ที่จะไว้เรียกจาก Client ได้ที่ jax-ws จะ auto generate ให้เป็น Method ใน jax-ws ให้เลยน่ะครับ
System.out.println("..... sayHello(String param[" + param + "])");

return "Hello " + param;
}

}

4. ต่อไปมาดูส่วนที่ต้อง Config เพิ่มเติมในส่วน web.xml
<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<description>Example Web Service</description>
<display-name>examplews</display-name>
<servlet-name>example</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>example</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

5. หลังจาก Config เสร็จแล้วจะต้องไปสร้าง sun-jaxws.xml เพื่อ Config ว่า Class ไหนบ้างเป็น Web Service แล้วมี Path เป็นอะไรน่ะครับ
<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
<endpoint name="hello" implementation="tutorial.jaxws.webservice.sample.Hello" <-- บอกว่าจะให้ Class นั้นเป็น Web Service url-pattern="/helloService" />
</endpoints>

6. สั่งรันเป็นอันเสร็จ เรียบร้อย จะได้ Web Service มาใช้งานแล้วครับ คร้าวหน้า จะมาเขียน jax-ws client ไว้สำหรับเรียกนะครับ ซึ่งมีทั้งแบบ Sync, Async ครับ

วันพฤหัสบดีที่ 18 มีนาคม พ.ศ. 2553

Weblogic and Maven Integration

ขอแปะเก็บไว้หน่อยนึง การใช้ maven ร่วมกับ Weblogic
http://mohanrajk.wordpress.com/2009/03/02/weblogic-103-and-maven-integration/
http://www.blogwitter.com/category/java/weblogic/

แก้ไขเรื่อง mvn weblogic:deploy ครับ ต้องไปแก้ที่ setting ของ maven ถ้าทำงานบน windows น่ะครับ http://timezra.blogspot.com/2009/06/maven-and-weblogic.html

เพิ่มเติมแก้ Bug บางอย่าง
http://forums.oracle.com/forums/thread.jspa?threadID=724768