我想访问提供的值application.properties
,例如:
logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR
logging.file=${HOME}/application.log
userBucket.path=${HOME}/bucket
Run Code Online (Sandbox Code Playgroud)
我想userBucket.path
在Spring Boot应用程序中访问我的主程序.
我看到了使用@Order
注释的代码.我想知道关于Spring Security或Spring MVC的这个注释有什么用处.
这是一个例子:
@Order(1)
public class StatelessAuthenticationSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService userDetailsService;
@Autowired
private TokenAuthenticationService tokenAuthenticationService;
}
Run Code Online (Sandbox Code Playgroud)
如果我们不使用这个注释,上面提到的类的顺序会发生什么?
我正在开发一个SpringBoot项目,我想用它的名字来获取bean applicationContext
.我已尝试过很多来自网络的解决方案,但无法成功.我的要求是我有一个控制器
ControllerA
Run Code Online (Sandbox Code Playgroud)
在控制器内我有一个方法getBean(String className)
.我想获取已注册bean的实例.我有hibernate实体,我想通过仅在getBean
方法中传递类的名称来获取bean的实例.
如果有人知道解决方案,请帮忙.
嗨朋友我正在开发一个基于spring boot maven的项目,并且我创建了一个maven子模块但是当我尝试运行我的项目时它会出错
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.2.5.RELEASE:run (default-cli) on project demo-jhipster: Unable to find a suitable main class, please add a 'mainClass' property -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.2.5.RELEASE:run (default-cli) on project demo-jhipster: Unable to find a suitable main class, please add a 'mainClass' property
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
Run Code Online (Sandbox Code Playgroud)
我的父母pom和孩子pom是
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" …
Run Code Online (Sandbox Code Playgroud) 嗨我正在使用Rest客户端即Postman发送REST请求但收到错误:
{
"timestamp": 1432829209385,
"status": 415,
"error": "Unsupported Media Type",
"exception": "org.springframework.web.HttpMediaTypeNotSupportedException",
"message": "Content type 'text/plain;charset=UTF-8' not supported",
"path": "/api/v1/user"
}
Run Code Online (Sandbox Code Playgroud)
我的控制器是:
@RequestMapping(value = "/user", method = RequestMethod.PUT, produces = "application/json")
public Map<String,Object> updateUser(@RequestBody @Valid User user) {
// userService.updateUser(user);
return ResponseHandler.generateResponse("", HttpStatus.ACCEPTED, false, null);
}
Run Code Online (Sandbox Code Playgroud)
我通过REST客户端发送请求,如图所示.
我想将消息记录在文件中而不是在控制台上.我正在使用Spring Boot,我的配置如下:
application.properties:
logging.level: DEBUG
logging.level: ERROR
logging.file: ${HOME}/application.log
Run Code Online (Sandbox Code Playgroud)
我只在我的application.log
文件中获取INFO的日志消息,但我也想要ERROR和DEBUG消息.
我的要求是我想要error.log
文件中的ERROR消息和DEBUG消息debug.log
以及INFO消息info.log
.
任何帮助非常感谢.
嗨朋友我正在开发弹簧启动项目,elastic search
我在本地机器上设置弹性搜索,我已经Head
在弹性搜索中安装了插件.我的弹性搜索设置正确显示绿色标志.我的项目中的application-dev.yml文件如下:
server:
port: 8080
liquibase:
context: dev
spring:
profiles:
active: dev
datasource:
dataSourceClassName: org.h2.jdbcx.JdbcDataSource
url: jdbc:h2:mem:jhipster;DB_CLOSE_DELAY=-1
databaseName:
serverName:
username:
password:
jpa:
database-platform: com.aquevix.demo.domain.util.FixedH2Dialect
database: H2
openInView: false
show_sql: true
generate-ddl: false
hibernate:
ddl-auto: none
naming-strategy: org.hibernate.cfg.EJB3NamingStrategy
properties:
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: true
hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
data:
elasticsearch:
cluster-name: elasticsearch
cluster-nodes: localhost:9200
messages:
cache-seconds: 1
thymeleaf:
mode: XHTML
cache: false
activemq:
broker-url: tcp://localhost:61616
metrics:
jmx.enabled: true
spark:
enabled: false
host: localhost
port: 9999
graphite:
enabled: false …
Run Code Online (Sandbox Code Playgroud)