- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我发现 Spring Boot 和 Spring Loaded 的基本示例设置无法根据文档进行工作。我按照 http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#getting-started-first-application 上的说明进行操作创建一个基本的应用程序,唯一的区别是我将我的类放入一个包中并使用父 pom 的发布版本。应用程序运行良好。然后我将 spring 加载到 pom 文件中,如 doco 中所述。
我使用 mvn spring-boot:run 运行应用程序。
更改我的 Controller 输出,例如“Hello World”到“Hello me”不支持热重载。
我尝试使用其他地方描述的 javaagent 命令行参数作为 java 应用程序运行,但这也不起作用。
pom 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>myproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.0.RELEASE</version>
</parent>
<!-- Additional lines to be added here... -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.1.RELEASE</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
编译的类可以在这里找到:project_dir\target\classes(我使用的是 Eclipse 和 m2e 插件)。
启动日志:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myproject 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.2.0.RELEASE:run (default-cli) @ myproject >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myproject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\dev\src\scrapi\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\dev\src\scrapi\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ myproject ---
[INFO] No sources to compile
[INFO]
[INFO] <<< spring-boot-maven-plugin:1.2.0.RELEASE:run (default-cli) @ myproject <<<
[INFO]
[INFO] --- spring-boot-maven-plugin:1.2.0.RELEASE:run (default-cli) @ myproject ---
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.0.RELEASE)
2015-01-02 13:23:25.311 INFO 2180 --- [.Example.main()] first.Example : Starting Example on DEFRAVD804016 with PID 2180 (C:\dev\src\scrapi\target\classes started by john in C:\dev\src\scrapi)
2015-01-02 13:23:25.359 INFO 2180 --- [.Example.main()] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@44354005: startup date [Fri Jan 02 13:23:25 CET 2015]; root of context hierarchy
2015-01-02 13:23:26.193 INFO 2180 --- [.Example.main()] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2015-01-02 13:23:27.121 INFO 2180 --- [.Example.main()] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8182/http
2015-01-02 13:23:27.689 INFO 2180 --- [.Example.main()] o.apache.catalina.core.StandardService : Starting service Tomcat
2015-01-02 13:23:27.691 INFO 2180 --- [.Example.main()] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.15
2015-01-02 13:23:27.814 INFO 2180 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2015-01-02 13:23:27.814 INFO 2180 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2457 ms
2015-01-02 13:23:28.653 INFO 2180 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2015-01-02 13:23:28.657 INFO 2180 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-01-02 13:23:28.657 INFO 2180 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-01-02 13:23:28.883 INFO 2180 --- [.Example.main()] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@44354005: startup date [Fri Jan 02 13:23:25 CET 2015]; root of context hierarchy
2015-01-02 13:23:28.995 INFO 2180 --- [.Example.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto java.lang.String first.Example.home()
2015-01-02 13:23:28.997 INFO 2180 --- [.Example.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2015-01-02 13:23:28.998 INFO 2180 --- [.Example.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2015-01-02 13:23:29.112 INFO 2180 --- [.Example.main()] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-01-02 13:23:29.112 INFO 2180 --- [.Example.main()] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-01-02 13:23:29.160 INFO 2180 --- [.Example.main()] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-01-02 13:23:29.268 INFO 2180 --- [.Example.main()] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2015-01-02 13:23:29.394 INFO 2180 --- [.Example.main()] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8182/http
2015-01-02 13:23:29.399 INFO 2180 --- [.Example.main()] first.Example : Started Example in 4.417 seconds (JVM running for 11.803)
在这种情况下我需要做什么才能使 Spring Loaded 工作?
最佳答案
我从来没有以这种方式加载 Spring 。就我个人而言,我使用每次都对我有效的“旧方法”。请尝试遵循以下步骤:
在 Eclipse 中打开运行/调试配置。
在左侧展开“Java 应用程序”选项并选择您的运行配置。 App
就我而言。设置错误配置是常见错误,因此请确保project
和main class
是正确的。
编辑VM arguments
并将其设置为 -javaagent:<spring_loaded_jar_file_path> -noverify
。如果您本地没有加载 spring,最简单的获取方法是 checkout their official repo 并运行 ./gradlew
.
A gradle build script is included, run './gradlew build' to rebuild the agent - it will be created as something like: springloaded/build/libs/springloaded-1.1.5.BUILD-SNAPSHOT.jar
现在您可以启动新配置。在浏览器中检查内容之前,请检查 eclipse 中的配置。右键单击您的 Java 应用程序并选择属性。
然后您应该看到您的应用程序正在使用 javaagent 运行。
请告诉我们这是否适合您。
关于eclipse - Spring Boot、Spring Loaded、Eclipse、Maven 基本示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27718939/
我试图理解 Maven 模块和 Maven 项目之间的区别。哪一个是什么以及我应该在哪里?谢谢 最佳答案 maven 模块就像一个 maven“子项目”。一个 Maven 项目包含 1 个或多个模块。
我们目前没有自己的存储库。因此,当我们使用 Maven 构建时,它会在当前用户的主目录中创建 .m2 存储库。 现在有两个在 Maven Central 中找不到的第三方 jar。假设其中之一是 ha
我有 Maven 项目,但在其中一台服务器上我必须在没有 Maven 的情况下构建它。 可以使用标准 JDK 命令。在哪里可以看到 Maven 在构建项目时向 JDK 发送了哪些命令? 最佳答案 Ma
我打算将 ImageJ 用于 web 应用程序,但似乎 ImageJ maven 依赖项不在中央 maven 存储库中。 我说得对吗? 当 ImageJ 2.x 发布时,这会改变吗? 最佳答案 您可以
我可以有多个 Maven 实例吗,即 Mave 2.2.1 和 Maven 3 都指向同一个本地存储库? 我的意思是我知道我可以在技术上将每个 settings.xml 指向同一个文件夹,但从长远来看
我有两个项目,项目 A 依赖于项目 B,所以通常,我的 projectA/pom.xml 中有以下部分: projectB blabla version1 我想要实现的目标非常简
在网上的许多地方,我看到它讨论了要使 maven 构建可重现,明确指定所有使用的插件的版本号很重要,这样更新的插件就不会破坏构建。推荐的方法似乎是使用 enforcer 插件。下面是我在网上找到的复制
有没有办法暂停 Maven 执行流程以提供命令提示符,以便用户可以输入文本。 然后我希望将提供的文本存储在 Maven 属性中。 如果用户输入可以被屏蔽,那将是一个奖励。 这对于避免在 pom.xml
我正在尝试使用 maven 插件将 maven java 项目的源文件夹添加到 Eclipse。 尝试使用 org.codehaus.mojo 插件时,我收到以下错误 无法在项目应用程序框架上执行目标
我有两个几乎相同的配置文件。我不想在每个配置文件中复制配置,而是希望一个配置文件从另一个配置文件“继承”,但我没有看到使用 maven 3 执行此操作的明显方法。 在 Maven 中是否可以继承配置文
我是 Maven 新手,花了大约 3 天的时间使用程序集插件生成 zip 文件,引用 http://www.petrikainulainen.net/programming/tips-and-tric
想象一下这种情况。我有一个使用 Maven 管理的开源项目,它依赖于一个不在 Maven 存储库中的知名库(例如 jpathwatch)。我怎样才能让它发挥作用? 直接的方法是将 jpathwatch
我将 Neo4j 和 MongoDB 与 Grails 一起使用,我想知道 Maven Neo4j 插件是否也为我的构建提供了 Neo4j 依赖项。 MongoDB 也是如此。 我很困惑。我应该使用什
我正在尝试同时发布多个 Maven 项目,将它们部署到 oss.sonatype.org,然后将它们发布到 Maven Central。 我有一个构建 pom,用于一起构建多个多模块项目。构建 pom
我有一个带有 maven pom.xml 的项目 4.0.0 Minimal-J Minimal-J 0.1-SNAPSHOT Minimal-J
我需要制作一个下载maven项目并打印其依赖项的小程序 像这样: MavenArtifactRepository repository = new MavenArtifactRepository("t
我有一个关于 maven 在构建过程中如何计算类路径的问题。具体来说,控制何时使用“目标/类”以及何时使用来自存储库(本地/远程)的“jar”。 我有一个版本为 1.0.0-SNAPSHOT 的项目,
我有一个 maven 项目,需要在命令行(-Dmy.property=val)设置一个属性。 我需要做的是将该字符串转换为所有大写,因为该属性是 用于通过 maven-resources-plugin
引用和转义如何对传递给 Maven 插件的参数起作用? 例如,我想将多个文件名作为参数传递给 Maven Exec 插件运行的应用程序: mvnDebug exec:java -Dexec.mainC
我在父 pom 的导入的 dependencyManagement 部分中指定了一个库版本。我确认我的有效 pom 只有一次出现这种依赖。它在依赖管理部分: org.jav
我是一名优秀的程序员,十分优秀!