我对弹簧安全URL的CORS过滤器有问题.它没有设置Access-Control-Allow-Origin
和属于spring sec(登录/注销)或由Spring Security过滤的URL上的其他公开标头.
这是配置.
CORS:
@Configuration
@EnableWebMvc
public class MyWebMvcConfig extends WebMvcConfigurerAdapter {
********some irrelevant configs************
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/*").allowedOrigins("*").allowedMethods("GET", "POST", "OPTIONS", "PUT")
.allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method",
"Access-Control-Request-Headers")
.exposedHeaders("Access-Control-Allow-Origin", "Access-Control-Allow-Credentials")
.allowCredentials(true).maxAge(3600);
}
}
Run Code Online (Sandbox Code Playgroud)
安全:
@Configuration
@EnableWebSecurity
public class OAuth2SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint).and()
.formLogin()
.successHandler(ajaxSuccessHandler)
.failureHandler(ajaxFailureHandler)
.loginProcessingUrl("/authentication")
.passwordParameter("password")
.usernameParameter("username")
.and()
.logout()
.deleteCookies("JSESSIONID")
.invalidateHttpSession(true)
.logoutUrl("/logout")
.logoutSuccessUrl("/")
.and()
.csrf().disable()
.anonymous().disable()
.authorizeRequests()
.antMatchers("/authentication").permitAll()
.antMatchers("/oauth/token").permitAll()
.antMatchers("/admin/*").access("hasRole('ROLE_ADMIN')")
.antMatchers("/user/*").access("hasRole('ROLE_USER')");
}
} …
Run Code Online (Sandbox Code Playgroud) 这是很难描述的问题。我有一个koajs
具有功能的应用程序,该功能每2分钟在多个实例(10-1000范围)中创建。此计划的作业是在应用启动时创建的。我使用它koajs
是因为我需要为此应用程序提供一些简单的api端点。在开始的3-5个小时中,它运行良好,然后创建的实例数开始减少,并且某些日志输出消失了。
这是基于实际代码的最小示例:
server.ts
const bootstrap = async () => {
process.setMaxListeners(0); //(node:7310) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added to [process]. Use emitter.setMaxListeners() to increase limit
//appears on app startup (however seems like this setMaxListeners(0) doesnt affect anything since the warning persist)
const app = new Koa();
app.use(async ctx => {
ctx.body = "Welcome to my Server!";
});
app.listen(port);
new Main().run();
};
bootstrap();
Run Code Online (Sandbox Code Playgroud)
main.ts(尝试:cron
NPM包,node-scheduler
,setInterval
,递归setTimeout
)来运行 …
我正在尝试使用弹簧启动后端为移动应用程序(离子3)实现1-1聊天.似乎遇到了一些配置问题.
无法发送消息可能是因为未创建目标通道
后端:
ChatController:
@RestController
public class ChatController {
@Autowired
private PrivateChatService privateChatService;
private final static Logger logger = LogManager.getLogger(ChatController.class.getName());
@RequestMapping(value = "/chat/messages/{item_id}/chat_with/{buyer_login}", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<String> getExistingChatMessages(@PathVariable("item_id") String itemId, @PathVariable("buyer_login") String buyerLogin) {
List<ChatMessage> messages = privateChatService.getExistingChatMessages(itemId, buyerLogin);
logger.info("Here get messages");
return JSONResponseHelper.createResponse(messages, HttpStatus.OK);
}
@MessageMapping("/chat/{item_id}/send")
@SendTo("/topic/chat/{item_id}/chat_with/{buyer_login}")
public ChatMessage send(@Payload ChatMessage message,
@DestinationVariable("item_id") String item_id) throws Exception {
// logger.info(principal.getName());
logger.info(message.toString());
logger.info(item_id);
privateChatService.submitMessage(message);
return message;
}
}
Run Code Online (Sandbox Code Playgroud)
WebSocketConfig:
@Configuration
@EnableWebSocketMessageBroker
@Order(Ordered.HIGHEST_PRECEDENCE + 99)
public class …
Run Code Online (Sandbox Code Playgroud) 我有一个使用Spring MVC + AngularJS的项目.所有数据都是动态的.在这个应用程序中有一些大的位置数据库.
出于搜索引擎优化的目的,需要为每个位置生成一个静态页面并将它们放在SEO友好的URL上(例如/ localhost/path1/path2/here-is-very-friendly-name)
制作它的最佳方法是什么?
我应该单独生成一个页面并将它们放在主应用程序的某个单独的文件夹中(如果是,最好的方法是什么?),或者我可以使用Spring/Angular吗?
(附加信息)
的每个位置的对象包括id
,name
,latitude
,longtitude
,address
,district
,city
,country
.
问候!
我正在尝试使用PyInstaller进行构建.配置:Python 3.6.5
pip 10.0.1
,操作系统:Ubuntu 18.04
.使用virtualenv
(也试过python -m venv
).
我的应用程序使用apscheduler
,websocket
,_thread
和它看起来像一些相关的模块有进口的问题.试过pyinstaller --onefile mymain.spec
&pyinstaller --onedir mymain.spec
.两种情况都存在问题.如果没有冻结,程序可以正常工作.
这是我尝试运行生成的可执行文件时得到的错误:
Traceback (most recent call last):
File "apscheduler/schedulers/base.py", line 882, in _create_plugin_instance
KeyError: 'interval'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "cmonitorcli/services/socket_client.py", line 70, in run
File "cmonitorcli/services/scheduler.py", line 36, in add_update_job
File "apscheduler/schedulers/base.py", line 413, in add_job
File …
Run Code Online (Sandbox Code Playgroud) 我想尝试在docker容器中运行Django应用程序的简单示例.
使用此图片https://hub.docker.com/_/django/ 只是为了简单起见.请不要告诉我,我不应该在生产中使用它:)应用程序非常简单,我可以使用非常基本的Django服务器.
所以,问题是我在尝试运行容器映像时总是遇到此错误
C:\Users\slipo\PycharmProjects\simple_blog>docker run -p 8000:8000 my-blog
python: can't open file './manage.py runserver 0.0.0.0:8000 --settings=mysite.settings.prod': [Errno 2] No such file or directory
Run Code Online (Sandbox Code Playgroud)
然而,./manage.py
与mysite.settings.prod
这两个绝对容器中现有.
容器创建日志 显示文件存在:
Step 7 : RUN ls -a
---> Running in 932ed2ad3e4c
.
..
.idea
Dockerfile
blog
manage.py
mysite
requirements.txt
templates
---> e7f938c1cbf2
Removing intermediate container 932ed2ad3e4c
Step 8 : CMD python ./manage.py runserver 0.0.0.0:8000 --settings=mysite.settings.prod
---> Running in f99bcafbc269
---> aca534e9ccb6
Removing intermediate container f99bcafbc269
Successfully …
Run Code Online (Sandbox Code Playgroud) 我已经使用 docker swarm 部署了硒网格。
docker-compose.yml
version: '3.7'
services:
hub:
image: selenium/hub:3.141.59-mercury
ports:
- "4444:4444"
volumes:
- /dev/shm:/dev/shm
privileged: true
environment:
HUB_HOST: hub
HUB_PORT: 4444
deploy:
resources:
limits:
memory: 5000M
restart_policy:
condition: on-failure
window: 240s
healthcheck:
test: ["CMD", "curl", "-I", "http://127.0.0.1:4444/wd/hub/status"]
interval: 1m
timeout: 60s
retries: 3
start_period: 300s
chrome:
image: selenium/node-chrome:latest
volumes:
- /dev/shm:/dev/shm
privileged: true
environment:
HUB_HOST: hub
HUB_PORT: 4444
NODE_MAX_INSTANCES: 5
NODE_MAX_SESSION: 5
deploy:
resources:
limits:
memory: 2800M
replicas: 10
entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh'
Run Code Online (Sandbox Code Playgroud)
问题是当hub …
我正在尝试 dockerize 我的 Spring 应用程序。
问题: 我无法从 docker 容器中获取 Spring 应用程序中的环境变量。
Spring 配置(2 个选项,单独尝试)
<bean class="java.net.URI" id="dbUrl">
<constructor-arg value="#{systemProperties['JDBC_CONNECTION_STRING']}"/>
</bean>
<bean class="java.net.URI" id="dbUrl">
<constructor-arg value="#{systemEnvironment['JDBC_CONNECTION_STRING']}"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
也试过java
URI dbUrl = URI.create(System.getProperty("JDBC_CONNECTION_STRING"));
Run Code Online (Sandbox Code Playgroud)
我的码头工人配置。使用docker-compose build
并docker-compose up
每次更新值。
docker-compose.yml
app:
build: .
command: catalina.sh run
ports:
- "8888:8080"
links:
- postgres
volumes:
- /usr/bin
postgres:
image: postgres:9.5
ports:
- "5432"
volumes:
- /var/lib/postgresql/data
Run Code Online (Sandbox Code Playgroud)
文件
FROM tomcat:jre8
ENV JDBC_CONNECTION_STRING 'postgres://postgres:password111@postgres:5432/mydb'
RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"]
RUN apt-get update && apt-get install -y …
Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个自定义的http拦截器,它将用于处理加载和其他附加功能.(手动处理每个请求的加载会显着增加代码量).
问题是: Loader在每个请求上被激活,但是loading.dismiss()
没有工作.(加载微调器一直处于活动状态,没有错误)
我的配置:
http拦截器:
@Injectable()
export class MyHttpWrapper extends Http {
private loading: any;
constructor(connectionBackend: ConnectionBackend, requestOptions: RequestOptions,private loadingCtrl: LoadingController) {
super(connectionBackend, requestOptions);
}
public get(url: string, options?: RequestOptionsArgs): Observable<Response> {
this.showLoader();
return super.get(url, this.getRequestOptionArgs(options))
.finally<Response>(() => {
this.hideLoader();
});
}
public post(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> {
return super.post(url, body, options);
}
public put(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> {
return super.put(url, body, options);
}
public delete(url: string, options?: RequestOptionsArgs): Observable<Response> {
return …
Run Code Online (Sandbox Code Playgroud) 我有一个使用pyinstaller生成的构建.我需要创建.rpm包,它将把可执行文件放入/usr/bin/
并创建一个运行该可执行文件的systemd服务.
我发现了这个 https://docs.python.org/3/distutils/builtdist.html和https://docs.python.org/2.0/dist/creating-rpms.html
但它并没有给我一个完整的图片.
有可能成功吗?
我需要使用什么工具集?(基本上,how
制作它).
如果可能 - 示例代码
docker ×3
javascript ×3
python ×3
spring ×3
dockerfile ×2
java ×2
pyinstaller ×2
python-3.x ×2
spring-boot ×2
typescript ×2
angular ×1
angularjs ×1
apscheduler ×1
cors ×1
django ×1
docker-swarm ×1
ionic2 ×1
ionic3 ×1
node.js ×1
rpm ×1
rpmbuild ×1
selenium ×1
seo ×1
spring-mvc ×1