- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 RequestMapping 注释在 Tomcat8 上部署一个 Spring MVC webapp。映射示例:
@Controller("brandController")
@RequestMapping("brand")
public class BrandController {
@Autowired
private BrandService brandService;
/**
* Creates or edits details about a specific Brand
* @param brand the brand to create/edit
*/
@RequestMapping(value="/save", consumes="application/json", produces="application/json", method=RequestMethod.POST)
public @ResponseBody Brand editBrand(@RequestBody Brand brand){
brandService.saveBrand(brand);
return brand;
}
...
}
网络.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
web.xml 引用了WEB-INF/dispatcher-servlet.xml,内容如下
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
<context:component-scan base-package="com.acme.web.controller"/>
<!-- Data Source -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<!-- Production Environment -->
<property name="driverClass" value="org.postgresql.Driver"/>
<property name="jdbcUrl" value="jdbc:postgresql://x.x.x.xx/mydb"/>
<property name="user" value="myuser"/>
<property name="password" value="mypass" />
<!-- c3p0 properties -->
<property name="acquireIncrement" value="3"/>
<property name="maxIdleTime" value="600"/><!-- seconds -->
<property name="minPoolSize" value="3"/>
<property name="maxPoolSize" value="6"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="com.acme.model"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="nestedTransactionAllowed" value="true"/>
</bean>
<tx:annotation-driven/>
<!-- scan for Spring MVC components -->
<mvc:annotation-driven/>
</beans>
catalina.out 日志如下 (loglevel = INFO)
26-Jan-2015 13:10:41.459 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
26-Jan-2015 13:10:41.521 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
26-Jan-2015 13:10:41.524 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
26-Jan-2015 13:10:41.525 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
26-Jan-2015 13:10:41.526 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 2574 ms
26-Jan-2015 13:10:41.596 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
26-Jan-2015 13:10:41.601 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.3
26-Jan-2015 13:10:41.680 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /home/me/apache-tomcat-8.0.3/webapps/ACME.war
26-Jan-2015 13:10:41.713 WARNING [localhost-startStop-1] org.apache.catalina.startup.SetContextPropertiesRule.begin [SetContextPropertiesRule]{Context} Setting property 'antiJARLocking' to 'true' did not find a matching property.
26-Jan-2015 13:10:47.897 INFO [localhost-startStop-1] org.apache.catalina.util.SessionIdGenerator.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [112] milliseconds.
2015-01-26 13:10:48,187 INFO [localhost-startStop-1] servlet.FrameworkServlet (FrameworkServlet.java:484) - FrameworkServlet 'dispatcher': initialization started
2015-01-26 13:10:48,218 INFO [localhost-startStop-1] support.AbstractApplicationContext (AbstractApplicationContext.java:510) - Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Mon Jan 26 13:10:48 GMT 2015]; root of context hierarchy
2015-01-26 13:10:48,274 INFO [localhost-startStop-1] xml.XmlBeanDefinitionReader (XmlBeanDefinitionReader.java:317) - Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
2015-01-26 13:10:49,172 INFO [localhost-startStop-1] log.MLog (MLog.java:92) - MLog clients using log4j logging.
2015-01-26 13:10:49,206 INFO [localhost-startStop-1] c3p0.C3P0Registry (C3P0Registry.java:216) - Initializing c3p0-0.9.2.1 [built 20-March-2013 10:47:27 +0000; debug? true; trace: 10]
26-Jan-2015 13:10:49.604 INFO [localhost-startStop-1] org.hibernate.annotations.common.reflection.java.JavaReflectionManager.<clinit> HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
26-Jan-2015 13:10:49.620 INFO [localhost-startStop-1] org.hibernate.Version.logVersion HHH000412: Hibernate Core {4.3.6.Final}
26-Jan-2015 13:10:49.625 INFO [localhost-startStop-1] org.hibernate.cfg.Environment.<clinit> HHH000206: hibernate.properties not found
26-Jan-2015 13:10:49.629 INFO [localhost-startStop-1] org.hibernate.cfg.Environment.buildBytecodeProvider HHH000021: Bytecode provider name : javassist
2015-01-26 13:10:50,015 INFO [localhost-startStop-1] impl.AbstractPoolBackedDataSource (AbstractPoolBackedDataSource.java:522) - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge2vb97an867f5dlj3r|2341b2f0, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.postgresql.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge2vb97an867f5dlj3r|2341b2f0, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:postgresql://xx.xx.xx.xx/mydb, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 600, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 6, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
26-Jan-2015 13:10:52.102 INFO [localhost-startStop-1] org.hibernate.dialect.Dialect.<init> HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
26-Jan-2015 13:10:52.123 INFO [localhost-startStop-1] org.hibernate.engine.jdbc.internal.LobCreatorBuilder.useContextualLobCreation HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
26-Jan-2015 13:10:52.208 INFO [localhost-startStop-1] org.hibernate.engine.transaction.internal.TransactionFactoryInitiator.initiateService HHH000399: Using default transaction strategy (direct JDBC transactions)
26-Jan-2015 13:10:52.222 INFO [localhost-startStop-1] org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory.<init> HHH000397: Using ASTQueryTranslatorFactory
26-Jan-2015 13:10:52.487 INFO [localhost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaValidator.validate HHH000229: Running schema validator
26-Jan-2015 13:10:52.487 INFO [localhost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaValidator.validate HHH000102: Fetching database metadata
2015-01-26 13:10:52,574 INFO [localhost-startStop-1] hibernate4.HibernateTransactionManager (HibernateTransactionManager.java:360) - Using DataSource [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge2vb97an867f5dlj3r|2341b2f0, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.postgresql.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge2vb97an867f5dlj3r|2341b2f0, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:postgresql://xx.xx.xx.xx/mydb, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 600, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 6, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]] of Hibernate SessionFactory for HibernateTransactionManager
2015-01-26 13:10:53,555 INFO [localhost-startStop-1] annotation.RequestMappingHandlerAdapter (RequestMappingHandlerAdapter.java:518) - Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Mon Jan 26 13:10:48 GMT 2015]; root of context hierarchy
2015-01-26 13:10:53,604 INFO [localhost-startStop-1] annotation.RequestMappingHandlerAdapter (RequestMappingHandlerAdapter.java:518) - Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Mon Jan 26 13:10:48 GMT 2015]; root of context hierarchy
2015-01-26 13:10:53,670 WARN [localhost-startStop-1] view.ContentNegotiatingViewResolver (ContentNegotiatingViewResolver.java:278) - Did not find any ViewResolvers to delegate to; please configure them using the 'viewResolvers' property on the ContentNegotiatingViewResolver
2015-01-26 13:10:53,701 INFO [localhost-startStop-1] servlet.FrameworkServlet (FrameworkServlet.java:503) - FrameworkServlet 'dispatcher': initialization completed in 5512 ms
26-Jan-2015 13:10:54.334 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
26-Jan-2015 13:10:54.339 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
26-Jan-2015 13:10:54.344 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 12817 ms
现在,如果我通过 Eclipse WTP 部署我的应用程序,映射将被拾取并且应用程序可以正常工作。但是,当我在“普通”Tomcat 8 容器中部署应用程序时,不会获取映射。
注意 Tomcat 的运行时包是完全一样的,唯一的区别是我在 Eclipse 和其他WEB-INF 中部署的库和类是相同的,因此我怀疑这与 Eclipse 自定义的一些设置有关,但我找不到任何相关差异。
你有什么想法吗?谢谢。
最佳答案
你的 Controller 在另一个模块中吗?也许 eclipse 将它部署为类,当你制作 war 文件时它不再在当前类文件夹中?
p.s:我认为这是资源问题。找不到任何原因可能是类的原因。不管怎样:D
关于java - 为什么在独立 Tomcat 上部署时我的 RequestMapping 没有被拾取?它适用于 Eclipse WTP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28149506/
@秋意正寒 先讲怎么用,再讲大致原理。 1 拾取坐标 > 仅拾取椭球体表面坐标 使用 Camera.prototype.pickEllipsoid 方法,接受一个必选的屏幕坐标,返回一个三维世界坐标
我知道 OpenGL 选择模式已被弃用,并且除了少数 SGI 盒和 3DLabs GPU 之外从未进行过硬件加速。但我无法摆脱它(不是我的代码)。在其 C++ 代码下方: void GLWidget:
我有一个 .ipa,里面有 arm64 和 armv7 个片段。如果我在同时支持 arm64 和 armv7 的 iDevice 上运行它,运行时将选择哪个切片? 我可以通过打印 NSLog 或某种方
我想在建模为高度图的世界地面上的 OpenGL 场景中跟踪鼠标坐标。目前没有像硬件镶嵌这样的花哨的东西。注意这个问题是不是 关于物体拾取。 目前我正在执行以下操作,由于回读操作,这显然会降低性能: 渲
我正在将一个数组从 php 传递到 javascript,但它似乎在数组的开头和结尾处拾取了一个额外的“。 我的数组从 PHP 文件发送 json_encode($CheckItems."|".$Ch
我的光线拾取代码有问题。我的代码 我正在使用此代码进行选择计算: /*----------------------------------------------------------- Funct
我需要根据特定深度(用于光线转换)将 2D 鼠标坐标转换为 3D 世界坐标。我没有直接在 C++ 中使用 DirectX,我使用的是专有语言,但如果你用 C++ 或伪代码(首选 C++)给我一个答案,
我正在开发一款等距游戏,但在制定方 block 选择算法时遇到了问题。 这就是我渲染等距 map 的方式: for (int x = 0; x < 50; x++) { for (int y
我尝试在应用程序中导出 UTI,但 macOS (10.3.2) 未拾取它。我已经在一个较小的项目中复制了我的问题。这是 info.plist 的相关部分: UTExportedTypeDeclara
我正在尝试使用 Pyglet 的 OpenGL 包装器实现拾取,但我在转换 C tutorial 时遇到了问题到 Python。具体在下面的部分。 #define BUFSIZE 512GLuint
我有一个定义为 singleTop 的 Activity,因此只有一个实例存在。 我用一些数据设置了一个 Notification Intent,并将其包含在 PendingIntent 中,
场景中有一些物体,有些可能会遮挡其他物体。当我单击鼠标或拖动选择以获得选择矩形时,我只想选择/拾取从这个角度可以看到的对象。应用程序当前使用 GL_SELECT 渲染模式,但正如我们所知,这也会选择被
我在一个小项目中使用了SpringBootApplication。架构很简单: 入口文件: @SpringBootApplication @PropertySource("classpath:appl
我有以下媒体查询,以选择 iPad 视网膜和更小的显示器。 @media only screen and (min-device-width : 768px) and (max-device-widt
我需要将 Oauth 设置为我将要处理的 PHP 项目的一部分。 为此我跑了; sudo pecl install oauth 这完成了 OK,它指示我将 extension=oauth.so 添加到
我正在尝试使用 Angular4 和 Google Analytics 集成自定义维度。我看过类似的主题,但没有任何内容可以准确解决这个问题。 在 GA 中我设置了自定义维度: 它以索引 1 显示:
我试图阻止用户与 vtkCaptionWidget 中的 anchor 进行交互 (http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/CaptionWi
我找不到使用光线追踪方法在 3D 中拾取的正确且可理解的表达方式。有人用任何语言实现过这个算法吗?分享直接工作的代码,因为由于伪代码无法编译,所以它们通常是由缺少的部分编写的。 最佳答案 您所拥有的是
我有一个相对较新的 MVC5 项目,正在使用 TeamCity 构建并由 Octopus Deploy 部署。一切都很棒,直到我通过 NuGet 添加 SQLite。当项目构建完成后,我在 bin 目
我正在尝试使用 Spring Data REST(版本 2.3.0.RELEASE)进行预测。我读了reference documentation ,并收集到这些是我需要的部分: JPA 实体 @En
我是一名优秀的程序员,十分优秀!