forked from springside/springside4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update boot-service to spring-boot 1.2.1 and more simple
also add h2 console to access embedded H2 in development env.
- Loading branch information
1 parent
6a788aa
commit df81d06
Showing
16 changed files
with
114 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
What is more? | ||
|
||
1. Use Jetty instead of Tomcat | ||
2. Don't use spring boot parent | ||
2. Use JavaSimon, demo AOP and Servlet mapping definition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/boot-service/src/main/java/org/springside/examples/bootservice/config/Profiles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.springside.examples.bootservice.config; | ||
|
||
public class Profiles { | ||
|
||
public static final String PRODUCTION = "production"; | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
.../boot-service/src/main/java/org/springside/examples/bootservice/config/WebConfigurer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.springside.examples.bootservice.config; | ||
|
||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.ServletRegistration; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.context.embedded.ServletContextInitializer; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.env.Environment; | ||
|
||
@Configuration | ||
public class WebConfigurer implements ServletContextInitializer { | ||
|
||
@Autowired | ||
private Environment env; | ||
|
||
@Override | ||
public void onStartup(ServletContext servletContext) | ||
throws ServletException { | ||
if (!env.acceptsProfiles(Profiles.PRODUCTION)) { | ||
initH2Console(servletContext); | ||
} | ||
} | ||
|
||
private void initH2Console(ServletContext servletContext) { | ||
ServletRegistration.Dynamic h2ConsoleServlet = servletContext | ||
.addServlet("H2Console", new org.h2.server.web.WebServlet()); | ||
h2ConsoleServlet.addMapping("/h2/*"); | ||
h2ConsoleServlet.setInitParameter("-properties", "src/main/resources"); | ||
h2ConsoleServlet.setLoadOnStartup(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
...t-service/src/main/java/org/springside/examples/bootservice/rest/IndexRestController.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
examples/boot-service/src/main/resources/.h2.server.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#H2 Server Properties | ||
#Fri Jan 09 00:37:05 CST 2015 | ||
0=TestDB(Embedded)|org.h2.Driver|jdbc\:h2\:mem\:testdb|sa | ||
webAllowOthers=false | ||
webPort=8082 | ||
webSSL=false |
19 changes: 3 additions & 16 deletions
19
examples/boot-service/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,14 @@ | ||
# server | ||
# server settings | ||
server.port=8080 | ||
management.port=7002 | ||
|
||
# logging | ||
logging.file=/tmp/logs/bootservice.log | ||
|
||
# pretty json format | ||
http.mappers.json-pretty-print=true | ||
http.mappers.json-sort-keys=true | ||
spring.jackson.serialization.INDENT_OUTPUT=true | ||
spring.datasource.sqlScriptEncoding=UTF-8 | ||
|
||
# disable spring boot strange behavior | ||
spring.main.show-banner=false | ||
spring.jpa.hibernate.ddl-auto=none | ||
spring.jpa.showsql=false | ||
|
||
#disable useless endpoints | ||
endpoints.autoconfig.enabled=false | ||
endpoints.beans.enabled=false | ||
endpoints.configprops.enabled=false | ||
endpoints.mappings.enabled=false | ||
endpoints.trace.enabled=false | ||
#endpoints.shutdown.enabled=true | ||
|
||
# /info endpoint | ||
info.app.name=Spring Boot Web Service Example | ||
info.app.version=${project.version} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Spring Boot Web Service Example</title> | ||
</head> | ||
<body> | ||
<p>Access below management endpoint: | ||
<ul> | ||
<li><a href="http://localhost:7002/health">http://localhost:7002/health</a></li> | ||
<li><a href="http://localhost:7002/info">http://localhost:7002/info</a></li> | ||
<li><a href="http://localhost:7002/dump">http://localhost:7002/dump</a></li> | ||
<li><a href="http://localhost:7002/metrics">http://localhost:7002/metrics</a></li> | ||
<li><a href="http://localhost:7002/env">http://localhost:7002/env</a></li> | ||
<li>shutdown(disable by default, POST method)</li></ul> | ||
</p> | ||
|
||
<p>JMX expose as Restful by jolokia. e.g. Tomcat's MBean: | ||
<ul> | ||
<li><a href="http://localhost:7002/jolokia/read/Tomcat:type=Connector,port=8080">http://localhost:7002/jolokia/read/Tomcat:type=Connector,port=8080</a></li> | ||
</ul> | ||
</p> | ||
|
||
<p>H2 Console in development profile: | ||
<ul> | ||
<li><a href="http://localhost:8080/h2">http://localhost:8080/h2/</a></li> | ||
</ul> | ||
</p> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.