我想学习一些完全基于注释的Spring MVC的基础知识。我从这个教程开始。
克隆存储库后
hg clone https://bitbucket.org/arnelism/snoutbook
和生成war
文件
mvn package
INFORMATION: Starting Servlet Engine: Apache Tomcat/7.0.12 Sep 12, 2014 3:37:18 PM org.apache.catalina.startup.HostConfig deployWAR INFORMATION: Deploying web application archive Snoutbook-1.0.0-SNAPSHOT.war Sep 12, 2014 3:37:27 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMATION: Deploying web application directory docs Sep 12, 2014 3:37:27 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMATION: Deploying web application directory examples Sep 12, 2014 3:37:27 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMATION: Deploying web application directory host-manager Sep 12, 2014 3:37:27 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMATION: Deploying web application directory manager Sep 12, 2014 3:37:27 PM org.apache.catalina.startup.HostConfig deployDirectory INFORMATION: Deploying web application directory ROOT Sep 12, 2014 3:37:27 PM org.apache.coyote.AbstractProtocolHandler start INFORMATION: Starting ProtocolHandler ["http-bio-8080"] Sep 12, 2014 3:37:27 PM org.apache.coyote.AbstractProtocolHandler start INFORMATION: Starting ProtocolHandler ["ajp-bio-8009"] Sep 12, 2014 3:37:27 PM org.apache.catalina.startup.Catalina start INFORMATION: Server startup in 8826 ms
http://localhost:8080/Snoutbook-1.0.0-SNAPSHOT/
12-Sep-2014 17:13:20.038 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployWAR Deploying web application archive D:\Users\b21090094\apac he-tomcat-8.0.12\webapps\Snoutbook-1.0.0-SNAPSHOT.war 12-Sep-2014 17:13:23.132 INFO [localhost-startStop-1] org.apache.catalina.util.S essionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for s ession ID generation using [SHA1PRNG] took [255] milliseconds. 12-Sep-2014 17:13:23.169 INFO [localhost-startStop-1] org.springframework.web.se rvlet.FrameworkServlet.initServletBean FrameworkServlet 'dispatcher': initializa tion started 12-Sep-2014 17:13:23.182 INFO [localhost-startStop-1] org.springframework.contex t.support.AbstractApplicationContext.prepareRefresh Refreshing WebApplicationCon text for namespace 'dispatcher-servlet': startup date [Fri Sep 12 17:13:23 CEST 2014]; root of context hierarchy 12-Sep-2014 17:13:23.278 INFO [localhost-startStop-1] org.springframework.contex t.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters JSR-250 'javax.annotation.ManagedBean' found and supported for component scannin g 12-Sep-2014 17:13:23.281 INFO [localhost-startStop-1] org.springframework.web.co ntext.support.AnnotationConfigWebApplicationContext.loadBeanDefinitions Register ing annotated classes: [class com.zeroturnaround.snoutbook.init.WebappConfigJpa] 12-Sep-2014 17:13:23.429 INFO [localhost-startStop-1] org.springframework.contex t.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters JSR-250 'javax.annotation.ManagedBean' found and supported for component scannin g 12-Sep-2014 17:13:23.921 INFO [localhost-startStop-1] org.springframework.beans. factory.support.DefaultListableBeanFactory.preInstantiateSingletons Pre-instanti ating singletons in org.springframework.beans.factory.support.DefaultListableBea nFactory@7169a1: defining beans [org.springframework.context.annotation.internal ConfigurationAnnotationProcessor,org.springframework.context.annotation.internal AutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequ iredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnn otationProcessor,org.springframework.context.annotation.internalPersistenceAnnot ationProcessor,webappConfigJpa,org.springframework.context.annotation.Configurat ionClassPostProcessor$ImportAwareBeanPostProcessor#0,addPetForm,snoutContoller,s noutDao,org.springframework.aop.config.internalAutoProxyCreator,delegatingWebMvc Configuration,requestMappingHandlerMapping,viewControllerHandlerMapping,beanName HandlerMapping,resourceHandlerMapping,defaultServletHandlerMapping,requestMappin gHandlerAdapter,mvcConversionService,mvcValidator,httpRequestHandlerAdapter,simp leControllerHandlerAdapter,handlerExceptionResolver,proxyTransactionManagementCo nfiguration,org.springframework.transaction.config.internalTransactionAdvisor,tr ansactionAttributeSource,transactionInterceptor,transactionManager,entityManager Factory,setupViewResolver,getDataSource]; root of factory hierarchy 12-Sep-2014 17:13:24.225 INFO [localhost-startStop-1] org.springframework.orm.jp a.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory Buildi ng JPA container EntityManagerFactory for persistence unit 'default' 12-Sep-2014 17:13:24.657 INFO [localhost-startStop-1] org.hibernate.annotations. common.Version. HCANN000001: Hibernate Commons Annotations {4.0.1.Final} 12-Sep-2014 17:13:24.676 INFO [localhost-startStop-1] org.hibernate.Version.logV ersion HHH000412: Hibernate Core {4.1.2} 12-Sep-2014 17:13:24.681 INFO [localhost-startStop-1] org.hibernate.cfg.Environm ent. HHH000206: hibernate.properties not found 12-Sep-2014 17:13:24.686 INFO [localhost-startStop-1] org.hibernate.cfg.Environm ent.buildBytecodeProvider HHH000021: Bytecode provider name : javassist 12-Sep-2014 17:13:24.772 INFO [localhost-startStop-1] org.hibernate.ejb.Ejb3Conf iguration.configure HHH000204: Processing PersistenceUnitInfo [ name: default ...] 12-Sep-2014 17:13:25.524 INFO [localhost-startStop-1] org.hibernate.service.jdbc .connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionP rovider HHH000130: Instantiating explicit connection provider: org.hibernate.ejb .connection.InjectedDataSourceConnectionProvider 12-Sep-2014 17:13:26.275 INFO [localhost-startStop-1] org.hibernate.dialect.Dial ect. HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect 12-Sep-2014 17:13:26.356 INFO [localhost-startStop-1] org.hibernate.engine.trans action.internal.TransactionFactoryInitiator.initiateService HHH000268: Transacti on strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFacto ry 12-Sep-2014 17:13:26.374 INFO [localhost-startStop-1] org.hibernate.hql.internal .ast.ASTQueryTranslatorFactory. HHH000397: Using ASTQueryTranslatorFactory 12-Sep-2014 17:13:26.498 INFO [localhost-startStop-1] . HV0000 01: Hibernate Validator 4.3.0.Final 12-Sep-2014 17:13:27.699 INFO [localhost-startStop-1] org.springframework.web.se rvlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod Mapped "{[/addP et],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.zeroturnaround.snoutbook.controllers.AddPetForm.setu pForm(org.springframework.ui.Model) 12-Sep-2014 17:13:27.700 INFO [localhost-startStop-1] org.springframework.web.se rvlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod Mapped "{[/addP et],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.zeroturnaround.snoutbook.controllers.AddPetForm.han dleSubmit(com.zeroturnaround.snoutbook.form.PetForm,org.springframework.validati on.BindingResult,org.springframework.web.bind.support.SessionStatus) 12-Sep-2014 17:13:27.701 INFO [localhost-startStop-1] org.springframework.web.se rvlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod Mapped "{[/pet/ {petId}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" ont o public java.lang.String com.zeroturnaround.snoutbook.controllers.SnoutContolle r.pet(java.lang.Long,org.springframework.ui.Model) 12-Sep-2014 17:13:27.702 INFO [localhost-startStop-1] org.springframework.web.se rvlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod Mapped "{[/owne rs],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto pub lic java.lang.String com.zeroturnaround.snoutbook.controllers.SnoutContoller.lis tOwners(org.springframework.ui.Model) 12-Sep-2014 17:13:27.762 INFO [localhost-startStop-1] org.springframework.web.se rvlet.handler.AbstractUrlHandlerMapping.registerHandler Mapped URL path [/**] on to handler of type [class org.springframework.web.servlet.resource.DefaultServle tHttpRequestHandler] 12-Sep-2014 17:13:28.129 INFO [localhost-startStop-1] org.springframework.web.se rvlet.FrameworkServlet.initServletBean FrameworkServlet 'dispatcher': initializa tion completed in 4960 ms 12-Sep-2014 17:13:28.140 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployWAR Deployment of web application archive D:\Users\b21090094\ apache-tomcat-8.0.12\webapps\Snoutbook-1.0.0-SNAPSHOT.war has finished in 8,103 ms 12-Sep-2014 17:13:28.141 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployDirectory Deploying web application directory D:\Users\b21090 094\apache-tomcat-8.0.12\webapps\docs 12-Sep-2014 17:13:28.167 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployDirectory Deployment of web application directory D:\Users\b2 1090094\apache-tomcat-8.0.12\webapps\docs has finished in 26 ms 12-Sep-2014 17:13:28.168 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployDirectory Deploying web application directory D:\Users\b21090 094\apache-tomcat-8.0.12\webapps\examples 12-Sep-2014 17:13:28.537 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployDirectory Deployment of web application directory D:\Users\b2 1090094\apache-tomcat-8.0.12\webapps\examples has finished in 370 ms 12-Sep-2014 17:13:28.538 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployDirectory Deploying web application directory D:\Users\b21090 094\apache-tomcat-8.0.12\webapps\host-manager 12-Sep-2014 17:13:28.572 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployDirectory Deployment of web application directory D:\Users\b2 1090094\apache-tomcat-8.0.12\webapps\host-manager has finished in 34 ms 12-Sep-2014 17:13:28.573 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployDirectory Deploying web application directory D:\Users\b21090 094\apache-tomcat-8.0.12\webapps\manager 12-Sep-2014 17:13:28.633 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployDirectory Deployment of web application directory D:\Users\b2 1090094\apache-tomcat-8.0.12\webapps\manager has finished in 61 ms 12-Sep-2014 17:13:28.633 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployDirectory Deploying web application directory D:\Users\b21090 094\apache-tomcat-8.0.12\webapps\ROOT 12-Sep-2014 17:13:28.659 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployDirectory Deployment of web application directory D:\Users\b2 1090094\apache-tomcat-8.0.12\webapps\ROOT has finished in 26 ms 12-Sep-2014 17:13:28.663 INFO [main] org.apache.coyote.AbstractProtocol.start St arting ProtocolHandler ["http-nio-8080"] 12-Sep-2014 17:13:28.676 INFO [main] org.apache.coyote.AbstractProtocol.start St arting ProtocolHandler ["ajp-nio-8009"] 12-Sep-2014 17:13:28.682 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 8701 ms
尝试使用http://localhost:8080/snoutbook-1.0.0-snapshot/owners
当您将war文件上传到tomcat的webapp文件夹时,默认情况下tomcat允许您使用war的名称访问webapp。然后,当您查看web app初始值设定器(web.xml
)时,它正在用/
映射注册DispatcherServlet
。接下来,查看控制器,它的@requestmapping
指向/owners
。因此,路径是:
主机:port
+war-name
+servlet-mapping
+controller-mapping
localhost:8080/
+snoutbook-1.0.0-快照/
+/
+所有者
等于
http://localhost:8080/snoutbook-1.0.0-snapshot/owners
我在Spring MVC中开发了一个应用程序,当我直接从eclipse通过run as->run On server运行它时,它工作得很好。 但是现在我想要将war部署到Tomcat文件夹并从那里运行它。我已经对此做了更改,war正在正确地部署到所需的tomcat文件夹中,但当我启动tomcat服务器并在浏览器中访问应用程序url时,它会给我404错误。服务器正在启动,没有任何异常。 下面是项目结
我有一个spring-boot项目在IntelliJ IDE中运行良好,我试图将其部署在Heroku服务器上。该项目部署成功,但当我试图从POSTMAN访问它时,我得到了503错误:服务不可用。 以下是从Heroku成功部署后的日志记录: Heroku的申请日志: 有人能帮帮我吗?提前谢了。
我想我也有类似的问题,但不知道如何修复Tomcat 404错误:源服务器没有找到目标资源的当前表示形式,或者不愿意透露该表示形式的存在 错误图像 我正在尝试使用docker和Tomcat构建简单的hello world spring boot应用程序。我用maven制作了war文件,然后将其放到$CATALINA_HOME/webapps/中,并通过执行[“CATALINA.sh”,“run”]来
每次都会出现以下错误!有相同的修复方法吗? 2021-10-07T10:47:31.133956 00:00heroku[路由器]: at=错误代码=H10 desc="应用程序崩溃"方法=GET路径="/"主机=zturlshortener.herokuapp.comrequest_id=c2f90e55-52f5-4955-a1d6-4028456cfddb fwd="103.199.173.
我已经在GCP上运行python 2.7应用程序大约5年了,并使用应用程序引擎启动器进行部署。 现在AEL已被弃用,我正试图通过gcloud部署,并得到“ERROR:(gcloud.app.deploy)” > 我运行了gCloud auth登录 但当我尝试重新部署我的应用程序时,我遇到了一个错误: 它没有给我太多继续下去的机会。想知道这是app.yaml的问题还是其他一些基本问题。 应用程序。y