forked from springside/springside4
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Calvin
committed
Dec 25, 2014
1 parent
6349135
commit e501181
Showing
15 changed files
with
272 additions
and
149 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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
Things not in demo | ||
|
||
1. use applicactionContextxml | ||
|
||
@ImportResource("applicationContext.xml") | ||
public class BootServiceApplication { | ||
} | ||
|
||
|
||
2. use Jetty instead of Tomcat | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-tomcat</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-jetty</artifactId> | ||
</dependency> | ||
|
||
3. disable web in junit test use spring context | ||
|
||
setWebEnvironment(false) | ||
|
||
4. set system exit code | ||
|
||
org.springframework.boot.ExitCodeGenerator | ||
|
||
5. read configuration | ||
@Value(${name}) | ||
String name | ||
|
||
or | ||
|
||
@Autowired | ||
Environment env; | ||
env.get | ||
|
||
6. set the configuration file path | ||
|
||
java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties | ||
|
||
or just change the file name | ||
|
||
java -jar myproject.jar --spring.config.name=myproject | ||
|
||
7. active profile | ||
java -jar myproject.jar --spring.profiles.active=dev,hsqldb | ||
|
||
SpringApplication.setAdditionalProfiles(…) | ||
|
||
8. define logging level in appliation.properties | ||
|
||
logging.level.org.springframework.web: DEBUG | ||
logging.level.org.hibernate: ERROR | ||
|
||
9. add spring-mvc defenation | ||
write WebMvcConfigurerAdapter without @EnableWebMvc | ||
|
||
10. add servlet/filter | ||
|
||
in application.properties | ||
|
||
ServletRegistrationBean or FilterRegistrationBean | ||
|
||
11. configure web | ||
|
||
1. add context path | ||
server.contextPath | ||
|
||
2. set tomcat threads | ||
|
||
12. JMX | ||
|
||
1. add new jmx | ||
@ManagedResource, @ManagedAttribute, @ManagedOperation | ||
|
||
2. change jmx default domian name | ||
endpoints.jmx.domain=myapp | ||
endpoints.jmx.uniqueNames=true | ||
|
||
|
||
13. APP id | ||
|
||
14. Custom Health information |
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
32 changes: 32 additions & 0 deletions
32
...s/boot-more/src/main/java/org/springside/examples/bootservice/common/JavaSimonConfig.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,32 @@ | ||
package org.springside.examples.bootservice.common; | ||
|
||
import org.javasimon.console.SimonConsoleServlet; | ||
import org.javasimon.spring.MonitoredMeasuringPointcut; | ||
import org.javasimon.spring.MonitoringInterceptor; | ||
import org.springframework.aop.support.DefaultPointcutAdvisor; | ||
import org.springframework.boot.context.embedded.ServletRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class JavaSimonConfig { | ||
|
||
// 定义AOP | ||
@Bean(name = "monitoringAdvisor") | ||
public DefaultPointcutAdvisor monitoringAdvisor() { | ||
DefaultPointcutAdvisor monitoringAdvisor = new DefaultPointcutAdvisor(); | ||
monitoringAdvisor.setAdvice(new MonitoringInterceptor()); | ||
monitoringAdvisor.setPointcut(new MonitoredMeasuringPointcut()); | ||
return monitoringAdvisor; | ||
} | ||
|
||
// 定义URL Mapping | ||
@Bean | ||
public ServletRegistrationBean dispatcherRegistration() { | ||
ServletRegistrationBean registration = new ServletRegistrationBean(new SimonConsoleServlet()); | ||
registration.addInitParameter("url-prefix", "/javasimon"); | ||
registration.addUrlMappings("/javasimon/*"); | ||
return registration; | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
examples/boot-more/src/main/resources/application-production.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
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
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
Oops, something went wrong.