我已经创建了spring boot web应用程序,但我无法在tomcat上部署spring boot web应用程序WAR文件,我可以将其作为java应用程序运行.如何在tomcat上将spring boot应用程序作为Web服务运行.我正在使用以下代码.如果可以在tomcat上运行,请在不使用web.xml和使用web.xml的情况下帮助我使用注释.
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
以下代码为休息控制器
@RestController
public class HelloWorld{
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public ResponseEntity<String> get() {
return new ResponseEntity<String>("Hello World", HttpStatus.OK);
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用Pom.xml
<groupId>org.springframework</groupId>
<artifactId>web-service</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId> …Run Code Online (Sandbox Code Playgroud) 如何在oracle中的单个语句中添加具有外键约束的新列.任何一个都可以提供示例查询.
spring注释配置@Named和之间的区别是什么@org.springframework.beans.factory.annotation.Qualifier?
哪个可用于为bean提供bean名称(就像'id'在xml配置中一样)?
有谁知道如何通过@PersistenceUnit批注通过构造函数设置EntityManagerFactory。我可以通过xml配置做到这一点。但我不知道相应的注释配置。
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="persistenceXmlLocation" value="classpath*:META-INF/persistence.xml" />
<property name="persistenceUnitName" value="myUnit"></property>
Run Code Online (Sandbox Code Playgroud)
<bean id="handler" class="com.handler.LocalHTHandler">
<constructor-arg ref="entityManagerFactory"></constructor-arg>
Run Code Online (Sandbox Code Playgroud)
而且工作正常。我们可以通过对我的处理程序bean的注释来做到这一点吗?我听说过@persistanceunit,但是不能将其放置在构造函数中来实现它。那是对的吗?
我仍然相信 Javascript 是单线程的,但是当我想到事件处理机制时,我有些怀疑。
为什么我认为即使在处理队列中的一个事件时,它也可以侦听或将事件推送到同一队列。我创建了一个示例,如下所示:
<html>
<head>
<script>
function clicked(){
alert("clicked in between..");
}
function longRun(){
for(var i=0;i<50000;i++){
console.log(i);
}
alert("completed .... ");
}
</script>
</head>
<body>
<input type="button" value="quick!" onclick="clicked();"/>
<input type="button" value="long run!" onclick="longRun();"/>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
当我点击长期运行!这需要一些时间才能完成,但与此同时,如果我点击快速!它将被添加到事件队列中,并在长期运行事件后立即执行。
实际发生了什么?谁能解释/纠正我
我知道Git有本地和远程repo(自分发以来),但我怀疑SVN提交和Git提交有什么区别(考虑本地git提交).
根据我的理解,这两个svn并且git将为每个提交维护整个项目的版本,而不是像CVS那样仅为提交的文件保留版本.这是真的吗?
那么,还有其他差异(除了两个系统存储版本信息的方式,提交到本地或中央仓库)?
我们正在测试通过邮递员休息客户端在泽西开发的REST Web服务.它是一个POST方法,并带有注释@RolesAllowed.完整注释方法如下:
@POST
@Path("/configuration")
@RolesAllowed("admin")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
Run Code Online (Sandbox Code Playgroud)
当我http://baseurl/configuration用预期的HTTP正文内容请求这个时,我得到了403响应(这是预期的,因为它似乎只允许管理员).
我怀疑的是如何通过rest客户端使用指定的角色访问此服务.
我们有春天的豆子:
@Component
@Scope(value="session")
public class MyBean {
// ...
}
Run Code Online (Sandbox Code Playgroud)
内部spring如何绑定HTTP作用域,如请求,会话与相应的bean的作用域.这有什么作用RequestContextListener吗?
在我的一个oracle表中,每行的一列中都有一个字符串'House Name'.我需要用'门牌号'代替它.我可以执行更新查询来查找并替换所有行中的此字符串.或者是否有任何内置函数.
java ×4
spring ×4
oracle ×2
sql ×2
annotations ×1
apache-spark ×1
ddl ×1
dom-events ×1
foreign-keys ×1
git ×1
javascript ×1
jersey ×1
jersey-2.0 ×1
jpa ×1
maven ×1
postman ×1
rdd ×1
spring-mvc ×1
str-replace ×1
svn ×1
tomcat ×1
web ×1