Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0 #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

1.0 #11

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion chapter2/pom.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -35,6 +35,12 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

<build>
Expand Down
3 changes: 2 additions & 1 deletion chapter2/src/main/java/com/dudu/Controller/UserController.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class UserController {
public String hexo(){
//return configBean.getName()+configBean.getWant();
//return yearhope;
return configBean.getName()+configBean.getWant();
System.out.println(yearhope);
return configTestBean.getName()+configTestBean.getWant();
}
}
2 changes: 1 addition & 1 deletion chapter2/src/main/java/com/dudu/domain/ConfigTestBean.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void setName(String name) {
}

public String getWant() {
return want;
return want+"sss";
}

public void setWant(String want) {
Expand Down
4 changes: 2 additions & 2 deletions chapter2/src/main/resources/application.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
com.dudu.name="\u561F\u561FMD"
com.dudu.want="\u795D\u5927\u5BB6\u9E21\u5E74\u5927\u5409\u5427"
com.dudu.name="MD"
com.dudu.want="TT"
com.dudu.yearhope=${com.dudu.name}\u5728\u6B64${com.dudu.want}
spring.profiles.active=dev
2 changes: 1 addition & 1 deletion chapter2/src/main/resources/config/application.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1 @@
server.port=8888
#server.port=8888
37 changes: 34 additions & 3 deletions chapter4/pom.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -29,7 +29,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -41,7 +44,28 @@
<artifactId>bootstrap</artifactId>
<version>3.3.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.1</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

<build>
Expand All @@ -50,8 +74,15 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>


</project>
7 changes: 5 additions & 2 deletions chapter4/src/main/java/com/dudu/controller/LearnResourceController.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.dudu.domain.LearnResouce;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
Expand Down Expand Up @@ -39,7 +40,8 @@ public ModelAndView index(){
learnList.add(bean);
bean =new LearnResouce("林祥纤博客系列","从零开始学Spring Boot ","http://412887952-qq-com.iteye.com/category/356333");
learnList.add(bean);
ModelAndView modelAndView = new ModelAndView("/index");
ModelAndView modelAndView = new ModelAndView("index");
System.out.println(learnList);
modelAndView.addObject("learnList", learnList);
return modelAndView;
}
Expand Down Expand Up @@ -68,7 +70,8 @@ public ModelAndView index2(){
learnList.add(bean);
bean =new LearnResouce("林祥纤博客系列","从零开始学Spring Boot ","http://412887952-qq-com.iteye.com/category/356333");
learnList.add(bean);
ModelAndView modelAndView = new ModelAndView("/template");
ModelAndView modelAndView = new ModelAndView("template");
System.out.println(learnList);
modelAndView.addObject("learnList", learnList);
return modelAndView;
}
Expand Down
1 change: 1 addition & 0 deletions chapter4/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
server.port=8008
1 change: 1 addition & 0 deletions chapter4/src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
server.port=8000
3 changes: 2 additions & 1 deletion chapter4/src/main/resources/application.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
spring.thymeleaf.cache=false
spring.thymeleaf.cache=false
spring.profiles.active=dev
2 changes: 1 addition & 1 deletion chapter4/src/main/resources/rebel.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">

<classpath>
<dir name="E:/springBootPro/chapter4/target/classes">
<dir name="/media/smart/377F3B312C263A87/项目/SpringBootDemo/chapter4/target/classes">
</dir>
</classpath>

Expand Down
8 changes: 6 additions & 2 deletions chapter5/pom.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand Down Expand Up @@ -62,7 +62,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.4.0</version>
</dependency>

</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion chapter5/src/main/java/com/dudu/Application.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
public class Application extends SpringBootServletInitializer {
Expand Down
2 changes: 1 addition & 1 deletion chapter55/pom.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand Down
2 changes: 1 addition & 1 deletion chapter55/src/main/java/com/dudu/Application.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
public class Application extends SpringBootServletInitializer {
Expand Down
29 changes: 26 additions & 3 deletions chapter6/pom.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -30,8 +30,6 @@
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>



<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand All @@ -42,6 +40,31 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
1 change: 1 addition & 0 deletions chapter6/src/main/java/com/dudu/Application.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dudu;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
package com.dudu.config;

import com.dudu.interceptor.MyInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
* Created by tengj on 2017/3/13.
*/
@Configuration
public class MyWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {
class MyWebMvcConfigurationSupport extends WebMvcConfigurationSupport {
@Autowired
MyInterceptor myInterceptor;

private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
//"classpath:/META-INF/resources/", "classpath:/resources/",
"classpath:/static/", "classpath:/public/"};

/**
* 配置静态访问资源
*
* @param registry
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//自定义项目内目录
//registry.addResourceHandler("/my/**").addResourceLocations("classpath:/my/");
registry.addResourceHandler("/**").addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);
//指向外部目录
registry.addResourceHandler("/my/**").addResourceLocations("file:E:/my/");
//registry.addResourceHandler("/my/**").addResourceLocations("file:E:/my/");
super.addResourceHandlers(registry);
}

Expand All @@ -36,18 +44,20 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/toLogin").setViewName("login");
registry.addViewController("/hi").setViewName("login");
super.addViewControllers(registry);
}

/**
* 拦截器
*
* @param registry
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
// addPathPatterns 用于添加拦截规则
// excludePathPatterns 用户排除拦截
registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**").excludePathPatterns("/toLogin","/login");
registry.addInterceptor(myInterceptor).addPathPatterns("/hi").excludePathPatterns("/toLogin", "/login");
super.addInterceptors(registry);
}
}
4 changes: 3 additions & 1 deletion chapter6/src/main/java/com/dudu/interceptor/MyInterceptor.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dudu.interceptor;

import com.dudu.domain.User;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
Expand All @@ -12,6 +13,7 @@
/**
* Created by tengj on 2017/3/29.
*/
@Component
public class MyInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Expand Down Expand Up @@ -52,6 +54,6 @@ public void postHandle(HttpServletRequest request, HttpServletResponse response,

@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {

System.out.println("done");
}
}
1 change: 1 addition & 0 deletions chapter6/src/main/resources/application.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# \u9ED8\u8BA4\u503C\u4E3A /**
#spring.mvc.static-path-pattern=/dudu/**
server.port=8080
Binary file added chapter7-1/lib/javax.ejb.jar
Binary file not shown.
Binary file added chapter7-1/lib/javax.jms.jar
Binary file not shown.
Binary file added chapter7-1/lib/javax.persistence.jar
Binary file not shown.
Binary file added chapter7-1/lib/javax.resource.jar
Binary file not shown.
Binary file added chapter7-1/lib/javax.servlet.jar
Binary file not shown.
Binary file added chapter7-1/lib/javax.servlet.jsp.jar
Binary file not shown.
Binary file added chapter7-1/lib/javax.servlet.jsp.jstl.jar
Binary file not shown.
Binary file added chapter7-1/lib/javax.transaction.jar
Binary file not shown.
Loading