Home Database Mysql Tutorial Problem with spring+mybatis+axis2 publishing webservice interface on myeclipse

Problem with spring+mybatis+axis2 publishing webservice interface on myeclipse

Jun 23, 2017 am 11:09 AM
myeclipse web webservice release interface

Premise:

Suddenly one day this month, there was a project docking that required the use of the interface published by axis2. This stumped me. After all, I didn’t even know how to publish the webservice interface before. Later, the first interface - sayHi() was released from HelloWorld; up to this step everything went smoothly. Only when integrating with axis2, a problem occurred. The dao layer of spring was in the interface after axis2 was released. , has always been null, it seems that spring has not been initialized. During this period, I tested to execute a request according to the normal process, and it was correct. However, it did not work after integrating with axis2. During this test, it was very painful. It's very painful. I have tried all imaginable methods one by one, including forced acquisition of dao and singleton mode, but nothing works. So I had to settle for the next best thing, first use spring+mybatis+cxf to publish a usable interface as a proxy, and then use the axis2 box to publish a separate method to call the proxy to achieve project docking. Let's start with the introduction of spring+mybatis+cxf:

1. Create the project directory:

First, we create an entity class Person.java

package com.srit.user.model;public class Person {private String id;  private String name;  private int age;  private String birthday;  private double hight;  public String getId() {  return id;  
    }  public void setId(String id) {  this.id = id;  
    }  public String getName() {  return name;  
    }  public void setName(String name) {  this.name = name;  
    }  public int getAge() {  return age;  
    }  public void setAge(int age) {  this.age = age;  
    }  public String getBirthday() {  return birthday;  
    }  public void setBirthday(String birthday) {  this.birthday = birthday;  
    }  public double getHight() {  return hight;  
    }  public void setHight(double hight) {  this.hight = hight;  
    }  
}
Copy after login

Then let’s first write PersonDao.java in dao. It is an interface. It mainly performs simple addition, deletion, modification and query

package com.srit.user.dao;import java.util.List;import javax.jws.WebMethod;import javax.jws.WebService;import com.srit.user.model.Person;public interface PersonDao {public void insertPerson(Person person);  public void updatePerson(Person person);  public List<Person> findPerson(String name);  public void deletePerson(String id);  
}
Copy after login

The following is the implementation class PersonDaoImpl.java

 1 package com.srit.user.dao.impl; 2  3 import java.util.List; 4  5 import javax.annotation.Resource; 6  7 import org.mybatis.spring.SqlSessionTemplate; 8 import org.mybatis.spring.support.SqlSessionDaoSupport; 9 10 import com.srit.user.dao.PersonDao;11 import com.srit.user.model.Person;12 13 public class PersonDaoImpl extends SqlSessionDaoSupport implements PersonDao {14 15     private SqlSessionTemplate sqlSessionTemplate;  
16     17     public SqlSessionTemplate getSqlSessionTemplate() {  
18         return sqlSessionTemplate;  
19     }  
20   21     @Resource(name="sqlSessionTemplate")    
22     public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {  
23         this.sqlSessionTemplate = sqlSessionTemplate;  
24     }  
25   26     public void deletePerson(String id) {  
27         getSqlSession().delete("com.srit.usr.dao.PersonDao.deletePerson", id);  
28     }  
29   30     public List<Person> findPerson(String name) {  
31         return getSqlSession().selectList("com.srit.user.dao.PersonDao.findPerson", name);  
32     }  
33   34     public void insertPerson(Person person) {  
35         getSqlSession().insert("com.srit.user.dao.PersonDao.insertPerson", person);  
36     }  
37   38     public void updatePerson(Person person) {  
39         getSqlSession().update("com.srit.user.dao.PersonDao.updatePerson", person);  
40     }  
41   42 43 }
Copy after login

of the dao layer, followed by the service layer PersonService.java

package com.srit.user.service;import java.util.List;import com.srit.user.model.Person;public interface PersonService {public void insertPerson(Person person);  public void updatePerson(Person person);  public List<Person> findPerson(String name);  public void deletePerson(String id); 
}
Copy after login

Next is the implementation class of the service layer, PersonServiceImpl.java

package com.srit.user.service.impl;import java.util.List;import javax.annotation.Resource;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Transactional;import org.springframework.web.context.ContextLoader;import org.springframework.web.context.WebApplicationContext;import com.srit.user.dao.PersonDao;import com.srit.user.model.Person;import com.srit.user.service.PersonService;

@Service  
@Transactional  
public class PersonServiceImpl implements PersonService {  
      
    @Resource  private PersonDao personDao;  
      public PersonDao getPersonDao() {  return personDao;  
    }  public void setPersonDao(PersonDao personDao) {  this.personDao = personDao;  
//        WebApplicationContext context=ContextLoader.getCurrentWebApplicationContext();//        personDao =(PersonDao)context.getBean("personDao");    }  
  public void deletePerson(String id) {  
        personDao.deletePerson(id);  
    }  
  public List<Person> findPerson(String name) {  return personDao.findPerson(name);  
    }  
  public void insertPerson(Person person) {  
        personDao.insertPerson(person);  
    }  
  public void updatePerson(Person person) {  
        personDao.updatePerson(person);  
    }  
  
}
Copy after login

, and then the service interface we want to publish, MyWebservice.java

1 package com.srit.user.webservice;2 3 import com.srit.user.model.Person;4 5 public interface MyWebservice {6     public String czDate(Person person); 
7 }
Copy after login

Of course it must have its implementation class MyWebserviceImpl.java

After get off work. . . Next time I’ll write

The above is the detailed content of Problem with spring+mybatis+axis2 publishing webservice interface on myeclipse. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to publish works on Xiaohongshu How to publish articles and pictures on Xiaohongshu How to publish works on Xiaohongshu How to publish articles and pictures on Xiaohongshu Mar 22, 2024 pm 09:21 PM

You can view various contents on Xiaohongshu, which can provide you with various help and help you discover a better life. If you have anything you want to share, you can post it here so that everyone can take a look. , and at the same time, it can bring you profits. It is very cost-effective. If you don’t know how to publish your works here, you can check out the tutorial. You can use this software every day and publish various contents to help everyone use it better. Don’t miss it if you need it! 1. Open Xiaohongshu and click the plus icon below. 2. There are [Video] [Picture] [Live Picture] options here; select the content you want to publish and click to check. 3. Select [Next] on the content editing page. 4. Enter the text content you want to publish and click [Publish Pen]

Why can't Xiaohongshu publish videos of works? How does it publish its work? Why can't Xiaohongshu publish videos of works? How does it publish its work? Mar 21, 2024 pm 06:36 PM

With the rapid development of social media, short video platforms have become the main channel for many users to express themselves and share their lives. Many users may encounter various problems when publishing videos of their works on Xiaohongshu. This article will discuss the reasons that may cause the video publishing of Xiaohongshu works to fail and provide the correct publishing method. 1. Why can’t Xiaohongshu publish videos of works? The Xiaohongshu platform may occasionally experience system failures, which may be caused by system maintenance or upgrades. In this case, users may encounter the problem of being unable to publish videos of their works. Users need to wait patiently for the platform to return to normal before trying to publish. An unstable or slow network connection may prevent users from posting videos of their work on Xiaohongshu. Users should confirm their network environment to ensure that the connection is stable and

Why can't Xiaohongshu be released? What should I do if the content published by Xiaohongshu cannot be displayed? Why can't Xiaohongshu be released? What should I do if the content published by Xiaohongshu cannot be displayed? Mar 21, 2024 pm 07:47 PM

As a lifestyle sharing platform, Xiaohongshu has attracted a large number of users to share their daily life and grow products. Many users have reported that their published content cannot be displayed. What is going on? This article will analyze the possible reasons why Xiaohongshu cannot be released and provide solutions. 1. Why can’t Xiaohongshu be released? Xiaohongshu implements strict community guidelines and has zero tolerance for publishing advertisements, spam, vulgar content, etc. If the user's content violates the regulations, the system will block it and the content will not be displayed. Xiaohongshu requires users to publish high-quality and valuable content, and the content needs to be unique and innovative. If the content is too generic and lacks innovation, it may not pass review and therefore not be displayed on the platform. 3. Account abnormality

How to delete Xiaohongshu releases? How to recover after deletion? How to delete Xiaohongshu releases? How to recover after deletion? Mar 21, 2024 pm 05:10 PM

As a popular social e-commerce platform, Xiaohongshu has attracted a large number of users to share their daily life and shopping experiences. Sometimes we may inadvertently publish some inappropriate content, which needs to be deleted in time to better maintain our personal image or comply with platform regulations. 1. How to delete Xiaohongshu releases? 1. Log in to your Xiaohongshu account and enter your personal homepage. 2. At the bottom of the personal homepage, find the &quot;My Creations&quot; option and click to enter. 3. On the &quot;My Creations&quot; page, you can see all published content, including notes, videos, etc. 4. Find the content that needs to be deleted and click the &quot;...&quot; button on the right. 5. In the pop-up menu, select the &quot;Delete&quot; option. 6. After confirming the deletion, the content will disappear from your personal homepage and public page.

When is the best time to publish Xiaohongshu? Where does it post the most traffic recommendations from? When is the best time to publish Xiaohongshu? Where does it post the most traffic recommendations from? Mar 21, 2024 pm 08:11 PM

In today's social network era, Xiaohongshu has become an important platform for young people to share their lives and obtain information. Many users hope to attract more attention and traffic by publishing content on Xiaohongshu. So, when is the best time to post content? This article will explore in detail the selection of Xiaohongshu’s publishing time and the publishing location with the most traffic recommendations. 1. When is the best time to publish Xiaohongshu? The best time to publish content on Xiaohongshu is usually during periods of high user activity. According to the characteristics and behavioral habits of Xiaohongshu users, there are several time periods that are more appropriate. During the time period from 7 pm to 9 pm, most users have returned home from get off work and started browsing content on their mobile phones in search of relaxation and entertainment. Therefore, content posted during this period is more likely to attract users

How to publish Xiaohongshu video works? What should I pay attention to when posting videos? How to publish Xiaohongshu video works? What should I pay attention to when posting videos? Mar 23, 2024 pm 08:50 PM

With the rise of short video platforms, Xiaohongshu has become a platform for many people to share their lives, express themselves, and gain traffic. On this platform, publishing video works is a very popular way of interaction. So, how to publish Xiaohongshu video works? 1. How to publish Xiaohongshu video works? First, make sure you have a video content ready to share. You can use your mobile phone or other camera equipment to shoot, but you need to pay attention to the image quality and sound clarity. 2. Edit the video: In order to make the work more attractive, you can edit the video. You can use professional video editing software, such as Douyin, Kuaishou, etc., to add filters, music, subtitles and other elements. 3. Choose a cover: The cover is the key to attracting users to click. Choose a clear and interesting picture as the cover to attract users to click on it.

How to publish Xiaohongshu content? How to delete content posted on Xiaohongshu? How to publish Xiaohongshu content? How to delete content posted on Xiaohongshu? Mar 21, 2024 pm 04:10 PM

With the continuous development of social media, Xiaohongshu has become an important platform for young people to share their lives, discover trends, and obtain inspiration. In this vibrant community, how to publish high-quality content and attract more attention and likes has become a concern for many users. 1. How to publish Xiaohongshu content? Before creating, it is crucial to choose a suitable topic. You can pick an engaging topic based on your interests and expertise. Doing so will not only keep you passionate about the writing process, but it will also make it easier for readers to relate to your work. 2. Carefully design the title: The title is the key to attracting readers to click. It should be concise and clear, and at the same time, it should be attractive and engaging. Avoid using exaggerated wording that may cause the reader to react

Where is Kuaishou published and how to change its location? How to add a location to a video that has been uploaded? Where is Kuaishou published and how to change its location? How to add a location to a video that has been uploaded? Mar 21, 2024 pm 06:00 PM

As a well-known short video platform in China, Kuaishou provides many creators with opportunities to showcase their talents and share their lives. When uploading a video, some novice creators may be confused about how to change the video posting location. This article will introduce you to how to change the publishing location of Kuaishou videos, and share some tips for Kuaishou video publishing to help you make better use of this platform to showcase your work. 1. Where is Kuaishou published and how to change its location? 1. Publishing interface: In Kuaishou APP, click the &quot;Publish&quot; button to enter the video publishing interface. 2. Location information: In the publishing interface, there is a &quot;Location&quot; column. Click to enter the location selection interface. 3. Change location: In the location selection interface, click the &quot;Location&quot; button to view the current location. If you want to change the location, click &quot;Location&quot;

See all articles