我正在使用web.xml创建项目springMvc + hibernate和Soap
但我的问题是当我用Tomcat 9开始它时。它打开了一个我不在我的代码中定义的页面。我不明白为什么它会自动打开。这是该页面:http://localhost8080:
这是我的代码:
文件web.xml:
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<!--
Main configuration file for this Spring web application.
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/config/spring-config.xml
</param-value>
</context-param>
<!--
Loads the Spring web application context, using the files defined above.
-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>services</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/config/spring-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>services</servlet-name>
<url-pattern>*.wsdl</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>services</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
文件spring-config.xml:
<beans xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- Config for soap -->
<context:component-scan base-package="com.higgsup.internship.soap" />
<bean id="users" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition" >
<property name="schemaCollection">
<bean class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
<property name="inline" value="true" />
<property name="xsds">
<list>
<value>schema/users.xsd</value>
</list>
</property>
</bean>
</property>
<property name="portTypeName" value="UserService"/>
<property name="serviceName" value="UserServices" />
<property name="locationUri" value="/ws"/>
</bean>
<!-- Enables the Spring MVC @Controller programming model -->
<!--<mvc:annotation-driven />-->
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<!--<mvc:resources mapping="/resources/**" location="/resources/" />-->
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/springmvc"/>
<property name="username" value="root"/>
<property name="password" value=""/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.higgsup.internship.soap.model" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<tx:annotation-driven />
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="userDao" class="com.higgsup.internship.soap.dao.UserDAOImpl"></bean>
文件UserDAOImpl:
public class UserDAOImpl implements UserDAO {
@PersistenceContext
private EntityManager entityManager;
public User getUser(Integer id) {
User user = entityManager.find(User.class, id);
return user;
}
public UserResponse show(UserRequest request){
UserResponse userResponse = new UserResponse();
UserForXML userForXML = new UserForXML();
User user = new User();
user = entityManager.find(User.class, request.getId());
userForXML.setUsername(user.getUsername());
userResponse.setUserForXML(userForXML);
return userResponse;
}
}
File UserEndpoint:
@Endpoint
public class UserEndpoint { private static final String NAMESPACE_URI =&#34; http://spring.io/guides/gs-producing-web-service&#34;;
@Autowired
private UserDAO userDao;
@PayloadRoot(localPart = "userRequest", namespace = NAMESPACE_URI)
@ResponsePayload
public UserResponse show(@RequestPayload UserRequest userRequest){
UserResponse userResponse = new UserResponse();
UserForXML userForXML = new UserForXML();
userForXML.setUsername("hung");
userResponse.setUserForXML(userForXML);
return userResponse;
}
}
File UserForXML:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "UserForXML", namespace = "http://com/higgsup/internship/soap", propOrder = {
"id",
"username",
"password",
"email"
}) 公共类UserForXML {
protected Integer id;
protected String username;
protected String password;
protected String email;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
文件UserRequest:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", namespace = "", propOrder = {
"id",
"username",
"password",
"email"
})
@XmlRootElement(name = "userRequest", namespace = "http://spring.io/guides/gs-producing-web-service")
public class UserRequest {
protected Integer id;
protected String username;
protected String password;
protected String email;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
文件UserResponse:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"userForXML"
})
@XmlRootElement(name = "userResponse", namespace = "http://spring.io/guides/gs-producing-web-service")
公共类UserResponse {
protected UserForXML userForXML;
public UserForXML getUserForXML() {
return userForXML;
}
public void setUserForXML(UserForXML userForXML) {
this.userForXML = userForXML;
}
}
这是日志:
03-Jul-2016 13:52:00.356 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log服务器版本:Apache Tomcat / 9.0.0.M4 03-Jul-2016 13:52:00.358 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log服务器内置:2016年3月12日11:39:59 UTC 03-Jul-2016 13:52:00.358 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log服务器编号:9.0.0.0 03-Jul-2016 13:52:00.358 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log操作系统名称:Windows 7 03-Jul-2016 13:52:00.358 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log操作系统版本:6.1 03-Jul-2016 13:52:00.358 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log架构:x86 03-Jul-2016 13:52:00.359 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java主页:C:\ Program Files(x86)\ Java \ jdk1.8.0_60 \ jre 03-Jul-2016 13:52:00.359 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM版本:1.8.0_60-b27 03-Jul-2016 13:52:00.359 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM供应商:Oracle Corporation 03-Jul-2016 13:52:00.359 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:C:\ Users \ hunghip.IntelliJIdea15 \ system \ tomcat \ Unnamed_spring-soap-hibernate-xml_2 03-Jul-2016 13:52:00.359 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:D:\ Setup \ tomcat \ apache-tomcat-9.0.0.M4 03-Jul-2016 13:52:00.359 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log命令行参数:-Dcom.sun.management.jmxremote = 03-Jul-2016 13:52:00.359 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log命令行参数:-Dcom.sun.management.jmxremote.port = 1099 03-Jul-2016 13:52:00.360 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log命令行参数:-Dcom.sun.management.jmxremote.ssl = false 03-Jul-2016 13:52:00.360 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log命令行参数:-Dcom.sun.management.jmxremote.authenticate = false 03-Jul-2016 13:52:00.360 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log命令行参数:-Djava.rmi.server.hostname = 127.0.0.1 03-Jul-2016 13:52:00.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log命令行参数:-Djava.util.logging.config.file = C:\ Users \ hunghip.IntelliJIdea15 \ system \ tomcat的\ Unnamed_spring皂,休眠,xml_2 \的conf \ logging.properties 03-Jul-2016 13:52:00.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log命令行参数:-Djava.util.logging.manager = org.apache.juli.ClassLoaderLogManager 03-Jul-2016 13:52:00.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log命令行参数:-Dcatalina.base = C:\ Users \ hunghip.IntelliJIdea15 \ system \ tomcat \ Unnamed_spring-soap -HIBERNATE-xml_2 03-Jul-2016 13:52:00.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log命令行参数:-Dcatalina.home = D:\ Setup \ tomcat \ apache-tomcat-9.0.0.M4 03-Jul-2016 13:52:00.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log命令行参数:-Djava.io.tmpdir = D:\ Setup \ tomcat \ apache-tomcat-9.0.0 .M4 \ TEMP 03-Jul-2016 13:52:00.361 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent使用APR版本1.5.2加载基于APR的Apache Tomcat Native库1.2.7。 03-Jul-2016 13:52:00.361 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR功能:IPv6 [true],sendfile [true],接受过滤器[false],随机[true]。 03-Jul-2016 13:52:01.851 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL已成功初始化(OpenSSL 1.0.2h 2016年5月3日) 03-Jul-2016 13:52:02.726 INFO [main] org.apache.coyote.AbstractProtocol.init初始化ProtocolHandler [&#34; http-nio-8080&#34;] 03-Jul-2016 13:52:02.816 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector使用共享选择器进行servlet写/读 03-Jul-2016 13:52:02.981 INFO [main] org.apache.coyote.AbstractProtocol.init初始化ProtocolHandler [&#34; ajp-nio-8009&#34;] 03-Jul-2016 13:52:02.982 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector使用共享选择器进行servlet写入/读取 03-Jul-2016 13:52:02.983 INFO [main] org.apache.catalina.startup.Catalina.load初始化处理时间为3866 ms 03-Jul-2016 13:52:03.240 INFO [main] org.apache.catalina.core.StandardService.startInternal开始服务Catalina 03-Jul-2016 13:52:03.240 INFO [main] org.apache.catalina.core.StandardEngine.startInternal启动Servlet引擎:Apache Tomcat / 9.0.0.M4 03-Jul-2016 13:52:03.248 INFO [main] org.apache.coyote.AbstractProtocol.start启动ProtocolHandler [http-nio-8080] 03-Jul-2016 13:52:03.260 INFO [main] org.apache.coyote.AbstractProtocol.start启动ProtocolHandler [ajp-nio-8009] 03-Jul-2016 13:52:03.262 INFO [main] org.apache.catalina.startup.Catalina.start服务器启动时间为279毫秒 连接到服务器 [2016-07-03 01:52:03,575]神器spring-soap-hibernate-xml:war:正在部署神器,请稍候...... 03-Jul-2016 13:52:08.427 INFO [RMI TCP连接(5)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars至少有一个JAR被扫描用于尚未包含TLD的TLD。为此记录器启用调试日志记录,以获取已扫描但未在其中找到TLD的完整JAR列表。在扫描期间跳过不需要的JAR可以缩短启动时间和JSP编译时间。 03-Jul-2016 13:52:08.538 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.web.context.ContextLoader.initWebApplicationContext根WebApplicationContext:初始化已启动 03-Jul-2016 13:52:08.695 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.web.context.support.XmlWebApplicationContext.prepareRefresh刷新根WebApplicationContext:启动日期[Sun Jul 03 13:52: 08 ICT 2016];上下文层次结构的根 03-Jul-2016 13:52:08.747 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions从ServletContext资源加载XML bean定义[/ WEB-INF / config /spring-config.xml] 03-Jul-2016 13:52:09.239 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor。 JSR-330&#39; javax.inject.Inject&#39;找到并支持自动装配的注释 03-Jul-2016 13:52:09.489 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory为持久性单元构建JPA容器EntityManagerFactory&#39;默认&#39; 03-Jul-2016 13:52:09.515 INFO [RMI TCP连接(5)-127.0.0.1] org.hibernate.jpa.internal.util.LogHelper.logPersistenceUnitInformation HHH000204:处理PersistenceUnitInfo [ 名称:默认 ...] 03-Jul-2016 13:52:09.642 INFO [RMI TCP连接(5)-127.0.0.1] org.hibernate.Version.logVersion HHH000412:Hibernate Core {5.2.1.Final} 03-Jul-2016 13:52:09.644 INFO [RMI TCP连接(5)-127.0.0.1] org.hibernate.cfg.Environment。 HHH000206:找不到hibernate.properties 03-Jul-2016 13:52:09.646 INFO [RMI TCP连接(5)-127.0.0.1] org.hibernate.cfg.Environment.buildBytecodeProvider HHH000021:字节码提供者名称:javassist 03-Jul-2016 13:52:09.740 INFO [RMI TCP连接(5)-127.0.0.1] org.hibernate.annotations.common.reflection.java.JavaReflectionManager。 HCANN000001:Hibernate Commons Annotations {5.0.1.Final} 03-Jul-2016 13:52:11.332 INFO [RMI TCP连接(5)-127.0.0.1] org.hibernate.dialect.Dialect。 HHH000400:使用方言:org.hibernate.dialect.MySQLDialect Hibernate:如果存在hibernate_sequence,则删除表 Hibernate:drop table if exists User Hibernate:创建表hibernate_sequence(next_val bigint) Hibernate:插入hibernate_sequence值(1) Hibernate:create table User(id integer not null,email varchar(255),password varchar(255),username varchar(255),primary key(id)) 03-Jul-2016 13:52:12.567 INFO [RMI TCP连接(5)-127.0.0.1] org.hibernate.tool.schema.internal.SchemaCreatorImpl.applyImportSources HHH000476:执行导入脚本&#39; org.hibernate.tool .schema.internal.exec.ScriptSourceInputNonExistentImpl @ e760c3&#39; 03-Jul-2016 13:52:12.597 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.buildNativeEntityManagerFactory初始化JPA EntityManagerFactory用于持久性单元&#39;默认&#39; 03-Jul-2016 13:52:12.826 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection.afterPropertiesSet已加载的ServletContext资源[/schema/users.xsd] 03-Jul-2016 13:52:13.105 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.web.context.ContextLoader.initWebApplicationContext根WebApplicationContext:初始化在4567 ms完成 03-Jul-2016 13:52:13.184 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.web.servlet.DispatcherServlet.initServletBean FrameworkServlet&#39; services&#39 ;:初始化已启动 03-Jul-2016 13:52:13.190 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.web.context.support.XmlWebApplicationContext.prepareRefresh刷新名称空间的WebApplicationContext&#39; services-servlet&#39; :启动日期[Sun Jul 03 13:52:13 ICT 2016]; parent:Root WebApplicationContext 03-Jul-2016 13:52:13.191 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions从ServletContext资源加载XML bean定义[/ WEB-INF / config /spring-config.xml] 03-Jul-2016 13:52:13.234 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor。 JSR-330&#39; javax.inject.Inject&#39;找到并支持自动装配的注释 03-Jul-2016 13:52:13.250 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory部署Web应用程序目录D:\ Setup \ tomcat \ apache-tomcat-9.0.0.M4 \的webapps \经理 03-Jul-2016 13:52:13.349 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory为持久性单元构建JPA容器EntityManagerFactory&#39;默认&#39; 03-Jul-2016 13:52:13.349 INFO [RMI TCP连接(5)-127.0.0.1] org.hibernate.jpa.internal.util.LogHelper.logPersistenceUnitInformation HHH000204:处理PersistenceUnitInfo [ 名称:默认 ...] 03-Jul-2016 13:52:13.366 INFO [RMI TCP连接(5)-127.0.0.1] org.hibernate.dialect.Dialect。 HHH000400:使用方言:org.hibernate.dialect.MySQLDialect Hibernate:如果存在hibernate_sequence,则删除表 Hibernate:drop table if exists User Hibernate:创建表hibernate_sequence(next_val bigint) Hibernate:插入hibernate_sequence值(1) Hibernate:create table User(id integer not null,email varchar(255),password varchar(255),username varchar(255),primary key(id)) 03-Jul-2016 13:52:13.496 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory部署Web应用程序目录D:\ Setup \ tomcat \ apache-tomcat-9.0.0.M4 \ webapps \ manager已在244毫秒内完成 03-Jul-2016 13:52:13.583 INFO [RMI TCP连接(5)-127.0.0.1] org.hibernate.tool.schema.internal.SchemaCreatorImpl.applyImportSources HHH000476:执行导入脚本&#39; org.hibernate.tool .schema.internal.exec.ScriptSourceInputNonExistentImpl @ e760c3&#39; 03-Jul-2016 13:52:13.591 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.buildNativeEntityManagerFactory初始化JPA EntityManagerFactory用于持久性单元&#39;默认&#39; 03-Jul-2016 13:52:13.620 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection.afterPropertiesSet已加载的ServletContext资源[/schema/users.xsd] 03-Jul-2016 13:52:14.031 INFO [RMI TCP连接(5)-127.0.0.1] org.springframework.web.servlet.DispatcherServlet.initServletBean FrameworkServlet&#39;服务&#39;:初始化在847 ms完成 [2016-07-03 01:52:14,145] Artifact spring-soap-hibernate-xml:war:神器已成功部署 [2016-07-03 01:52:14,145] Artifact spring-soap-hibernate-xml:war:Deploy花了10,570毫秒
答案 0 :(得分:0)
通常,Web服务API会生成一个动态页面,或者在这种情况下是一个示例页面,以列出所有已配置的端点。
每个端点都有一个WSDL来描述Web服务方法和客户端调用服务所需的地址。像这样:vec3
地址端点位于该WSDL的末尾:
nuget restore YourSolution.sln