我正进入(状态
java.lang.ClassNotFoundException: org.apache.jasper.runtime.JspApplicationContextImpl
Run Code Online (Sandbox Code Playgroud)
使用jetty时:在web项目上运行插件.
在处理某些问题时,问题只发生在某些机器上!
使用的Java版本:7 Maven版本:3.1
相关的依赖项和插件: -


我使用Spring Cloud和Zuul代理作为我的RESTful服务的网关.
网关应用程序(在端口8080上运行的Spring Boot Web应用程序)相关代码: -
主要课程: -
@SpringBootApplication
@EnableZuulProxy
public class WebfrontApplication extends WebMvcConfigurerAdapter {
/**
* @param args
*/
public static void main(String[] args) {
SpringApplication.run(WebfrontApplication.class, args);
}
Run Code Online (Sandbox Code Playgroud)
}
Zuul Mappings: -
zuul:
routes:
customer:
path: /customer/**
url: http://localhost:9000/
Run Code Online (Sandbox Code Playgroud)
在启动上述UI网关应用程序期间,我可以在我的日志中看到代理的映射已注册: -
o.s.c.n.zuul.web.ZuulHandlerMapping : Mapped URL path [/customer/**] onto handler of type [class org.springframework.cloud.netflix.zuul.web.ZuulController]
Run Code Online (Sandbox Code Playgroud)
REST服务(在端口9000上运行的Spring Boot Web应用程序)相关代码: -
@RestController
@RequestMapping(value = "/customer")
public class CustomerController {
@Autowired
private CustomerService customerService;
/**
* Get List of All customers.
*
* …Run Code Online (Sandbox Code Playgroud) spring-mvc spring-security spring-boot spring-cloud netflix-zuul
我遵循Spring Boot Security入门的第V部分来保护我的RESTful微服务.
我打算实施的简单流程是: -
如果未经身份验证,则会将用户重定向到自定义登录页面,例如"/ login".
用户提供他的凭据.
成功验证后,用户将被重定向到主页('/ home').在请求中提供访问令牌后,我应该能够访问我的REST端点(在Zuul代理服务器后面).
上述链接中的"入门指南"使用在.properties或.yml文件中配置的Basic Auth和虚拟用户.
这是我尝试配置的方式: -
@Configuration
@EnableAuthorizationServer
public class OAuth2Config extends AuthorizationServerConfigurerAdapter {
@Autowired
private AuthenticationManager authenticationManager;
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.authenticationManager(authenticationManager);
}
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory().withClient("acme").secret("acmesecret")
.authorizedGrantTypes("authorization_code", "refresh_token", "password").scopes("openid")
.accessTokenValiditySeconds(3600);
}
@Override
public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
oauthServer.tokenKeyAccess("isAnonymous()").checkTokenAccess("isAnonymous()")
.allowFormAuthenticationForClients();
}
}
@Configuration
@Import({ OptoSoftSecurityServiceConfig.class })
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService userDetailsService; // backed …Run Code Online (Sandbox Code Playgroud) 我正在将工作XML配置迁移到Spring Security OAuth2的Java配置,并使用Google作为OAuth提供程序.
这是我的java配置的外观:
@Configuration
@EnableWebMvcSecurity
@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
private static final List<String> scope;
static {
// Permissions to access email and profile
scope = new ArrayList<>(3);
scope.add("openid");
scope.add("email");
scope.add("profile");
}
@Autowired(required = true)
private UserService userService;
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http.
authorizeRequests()
.antMatchers(HttpMethod.GET, "/","/public/**", "/resources/**","/resources/public/**").permitAll()
//.antMatchers("/google_oauth2_login").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/")
.loginProcessingUrl("/login")
.defaultSuccessUrl("/home")
.and()
.csrf().disable() …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Google OAuth2 api获取用户的个人资料.用户身份验证后,在同意页面上,我总是被要求"有脱机访问"
浏览器中的URL如下所示: -
https://accounts.google.com/o/oauth2/auth?scope = email&response_type = code&redirect_uri = HTTPS://localhost/google_oauth2_login&state=YbzrDo&client_id=asdfasdf-60qhnqf6asdfasdfasdfcopo3plhoj.apps.googleusercontent.com&hl=en-US&from_login=1&as=604c0f3asdfasdf
如上面的URL所示,我已将范围参数作为' email ' 传递
Google Auth API页面说: -
"此范围要求您的应用可以访问:
用户的Google帐户电子邮件地址.您可以通过调用people.get来访问电子邮件地址,该人员返回电子邮件数组(或通过调用people.getOpenIdConnect,它返回符合OIDC格式的电子邮件属性).用户所属的Google Apps域名(如果有).域名从people.get(或getOpenIdConnect的hd属性)返回为域属性.此电子邮件范围等同于并取代了 https://www.googleapis.com/auth/userinfo.email范围."
为什么每次都要求我进行离线访问?


如何在Spring Boot 1.2.x中配置带有SSL连接器的Jetty?
以下配置适用于Spring引导1.1.6,但是为版本1.2.1 提供了"SslSocketConnector无法解析为类型"错误.
@Configuration
@EnableAutoConfiguration
public class OptosoftOAuthSecurityApplication implements
EmbeddedServletContainerCustomizer {
public static void main(String[] args) {
SpringApplication.run(OptosoftOAuthSecurityApplication.class, args);
}
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (container instanceof JettyEmbeddedServletContainerFactory) {
customizeJetty((JettyEmbeddedServletContainerFactory) container);
}
}
public void customizeJetty(
JettyEmbeddedServletContainerFactory containerFactory) {
containerFactory.addServerCustomizers(jettyServerCustomizer());
}
@Bean
public JettyServerCustomizer jettyServerCustomizer() {
return new JettyServerCustomizer() {
@Override
public void customize(Server server) {
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePassword("jetty6");
try {
sslContextFactory.setKeyStorePath(ResourceUtils.getFile(
"classpath:jetty-ssl.keystore").getAbsolutePath());
} catch (FileNotFoundException ex) {
throw new IllegalStateException("Could …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 PosgreSQL 作为数据库的普通 Spring 批处理应用程序。
pom.xml:-
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
<exclusions>
<exclusion>
<artifactId>hsqldb</artifactId>
<groupId>org.hsqldb</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我已明确排除“hsqldb”以确保 Spring 批处理使用 posgres。添加此依赖项可以解决问题,但我不想在我的设置中使用 hsqldb。
配置等级:-
@SpringBootApplication
@EnableBatchProcessing
public class Application {
private static Logger LOG = LoggerFactory.getLogger(Application.class); …Run Code Online (Sandbox Code Playgroud) 参考oauth2 spring-guides项目中的注销流程,一旦用户首次使用用户名/密码进行了身份验证,则注销后下次将不要求提供凭据。
如何确保每次注销后都要求输入用户名/密码。
这就是我要实现的:
OAuth2服务器使用具有自动批准功能的“ authorization_code”授予类型发布JWT令牌。这具有html / angularjs表单来收集用户名/密码。
UI / Webfront-使用@EnableSSO。其所有端点均已通过身份验证,即,它没有用户单击以转到/ uaa服务器的任何未经授权的登录页面/ ui /链接。因此,点击http:// localhost:8080会 立即将您重定向到http:// localhost:9999 / uaa并显示自定义表单以收集用户名/密码。
使用上述方法,我无法锻炼注销流程。到UI应用程序的HTTP POST / logout清除了UI应用程序中的会话/身份验证,但用户再次自动登录(因为我选择了所有范围的自动批准),而无需再次询问用户名密码。
查看日志和网络呼叫,似乎所有“ oauth舞动”都成功地再次发生,而无需再次要求用户输入用户名/密码,并且似乎auth服务器记住了为客户端发布的最后一个auth令牌(使用org.springframework .security.oauth2.provider.code.InMemoryAuthorizationCodeServices?)。
我如何告诉认证服务器每次要求输入用户名/密码的代码/令牌-无状态。
还是在给定方案中实现注销的最佳方法是什么。
(要重新创建一些接近我的要求的内容,请permitAll()从UiApplication中删除一部分,然后autoApproval在上述启动项目的身份验证服务器中进行配置。)
我正在使用由普通数组作为数据源支持的Angular Material Table.
this.employees = this.route.snapshot.data.employes; // of type Employee[] resolved using a Resolve guard
this.dataSource = new MatTableDataSource<Employee>(this.employees);
Run Code Online (Sandbox Code Playgroud)
一旦最初渲染,我想通过使用我的组件中的方法修改'this.employess'数组来添加/删除数据表中的行: -
addEmployee(e: Employee){
this.employess.push(e); // I expect the table to have one row added after this.
}
removeEmployee(index : number){
// splice the array at given index & remove one row from data table
}
Run Code Online (Sandbox Code Playgroud)
问题
当我在数组中添加remove元素时,数据表行不受影响.我发现一个博客详细说明了相同的问题但使用了自定义数据源.有没有办法使用普通数组?
我试图理解ng-if与ng-show的对比.在阅读完文档并在此处查看相关的stackoverflow问题之后,我理解ng-if删除了DOM元素,并且删除了ng-if中的范围变量.在'removed'ng-if元素中的ng-model变量不会出现在$ scope中.
来自Angular ng-if文档: -
请注意,使用ngIf删除元素时,其范围将被销毁,并且在还原元素时会创建新范围.在ngIf中创建的作用域使用原型继承从其父作用域继承.这一点的一个重要含义是,如果在ngIf中使用ngModel绑定到父作用域中定义的javascript原语.
请考虑以下代码段: -
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.10/angular.min.js"></script>
</head>
<body data-ng-app="myModule">
<div data-ng-controller="TestController">
<input name="first" type="number" data-ng-model="form.x" placeholder="Enter Number X"/>
<input name="second" type="number" data-ng-if="form.x>5" data-ng-model="form.y" placeholder="Enter Number Y"/>
<input type="button" value="Click" ng-click="save()"/>
</div>
<script type="text/javascript">
var myModule = angular.module("myModule",[]);
myModule.controller("TestController",function($scope){
$scope.form = {};
$scope.form.x = 0;
$scope.form.y = 0;
$scope.save = function(){
console.log($scope.form);
};
});
</script>
</html>
Run Code Online (Sandbox Code Playgroud)
这是一个非常简单的用例 - 只有当first大于5时才显示第二个数字输入字段.
保存按钮单击委托控制器中的"保存"功能,它只打印出$ scope的'form'对象.
输入1: - 输入x = 6,y = 2输出1:{x:6,y:2} …
spring-boot ×4
google-oauth ×2
angular ×1
angularjs ×1
jetty-9 ×1
maven-3 ×1
netflix-zuul ×1
oauth-2.0 ×1
postgresql ×1
spring-batch ×1
spring-cloud ×1
spring-mvc ×1
ssl ×1