小编Mag*_*o C的帖子

将Spring Boot版本从2.0.3.RELEASE更改为2.1.0.BUILD-SNAPSHOT时出现问题

我有停止的时候,我从改变春节引导版本一起使用工作代码2.0.3.RELEASE2.1.0.BUILD-SNAPSHOT.

有时错误是:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'dataSource', defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Run Code Online (Sandbox Code Playgroud)

要么 ...

Error starting ApplicationContext. To …
Run Code Online (Sandbox Code Playgroud)

spring-boot

27
推荐指数
1
解决办法
2万
查看次数

如何使用Spring使用OAuth2保护MVC应用程序?

对不起,我的英文.

我有一个应用程序,我可以通常的方式登录.

@Configuration
@EnableWebSecurity
public class LoginSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        System.out.println("LoginSecurityConfig :: configure");

        auth.jdbcAuthentication().dataSource( getDataSource() )
            .passwordEncoder( new BCryptPasswordEncoder(16) )
            .usersByUsernameQuery(
                "select user_name as username,password,enabled from users where user_name=?")
            .authoritiesByUsernameQuery(
                "select user_name as username, role_name from users_roles ur join users u on ur.user_id = u.user_id and u.user_name = ?");

    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {


        http
        .csrf().disable()
        .authorizeRequests()
        .antMatchers("/login*").anonymous()
        .antMatchers("/resources/**").permitAll()
        .antMatchers("/fotos/**").permitAll()
        .antMatchers("/users").access("hasRole('ROLE_ADMIN')")
        .antMatchers("/user").access("hasRole('ROLE_ADMIN')")
        .anyRequest().authenticated()
        .and()

        .formLogin()
        .loginPage("/loginPage")
        .defaultSuccessUrl("/home", true) …
Run Code Online (Sandbox Code Playgroud)

spring-mvc spring-security-oauth2

10
推荐指数
2
解决办法
1013
查看次数

Spring Tool Suite IDE不突出显示JSP文件

我必须创建一个Spring Boot WEB应用程序,但是JSP页面显示为纯文本,没有任何突出显示或标记。

如何配置STS以像Eclipse一样显示JSP文件?

使用STS 4.0.0.M12。

jsp spring-tool-suite

6
推荐指数
2
解决办法
3952
查看次数

如何在Cytoscape.JS节点内容中设置多个文本行?

我有一些cytoscape节点

  style: cytoscape.stylesheet()
    .selector('node')
      .css({
        'border-color': '#0266C8',
        'border-width' : '1px',
        'shape': 'data(faveShape)',
        'width': '80px',
        'font-family' : 'Consolas',
        'font-size' : '10px',
        'content': 'data(id)',
        'text-valign': 'center',
        'background-color': 'data(faveColor)',
        'color': 'data(textColor)'
      })
      ...
Run Code Online (Sandbox Code Playgroud)

如何使内容包含两行或更多行以及2个或更多串联字符串?

...
'content': 'data(id)' + '<br>' + data('name') + '<br>test123',
...
Run Code Online (Sandbox Code Playgroud)

TIA

javascript cytoscape.js

5
推荐指数
1
解决办法
2035
查看次数

如何在更新父母时删除孩子?

我有“父”和“子”休眠实体。

在“父母”上,我有一个Set<Child>持有它的孩子。

当我用新的孩子更新 Parent 时,一切正常:孩子是在“child”表上创建的。

但是,当我从父哈希集中删除一个元素并保存时,不会删除数据库上的对应子项。

这是:

在 PARENT(命名为工作流)上:

@OneToMany(orphanRemoval=true, cascade = CascadeType.ALL, mappedBy="workflow", fetch = FetchType.EAGER)
private Set<ActivityDB> activities; 
Run Code Online (Sandbox Code Playgroud)

关于孩子(命名活动)

@ManyToOne
@JoinColumn(name="id_workflow")
@Fetch(FetchMode.JOIN)
private WorkflowDB workflow;
Run Code Online (Sandbox Code Playgroud)

我正在会话中处理持久性实例。没有出现错误。似乎工作正常,但数据库上的寄存器仍然存在。

为了进行测试,我加载工作流并执行

workflow.activities.remove( activity_index_x )
Run Code Online (Sandbox Code Playgroud)

然后使用session.update( workflow ). 但是“activity_index_x”仍然在数据库中,当我重新加载工作流程时,它会再次出现。

java orm hibernate jpa hibernate-mapping

5
推荐指数
1
解决办法
3172
查看次数

Apache Tomcat服务器不在列表中添加新的

我需要添加一个Apache Tomcat服务器,但"Apache"文件夹只有Geronimo服务器.

如何解决这个问题?

STS 4.0.0.0.M12

在此输入图像描述

spring-tool-suite

4
推荐指数
1
解决办法
2639
查看次数

Spring Boot 2.2.0和Maven插件出现问题

我有两个项目。一项如下(例如项目1):

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
    <relativePath/> 
</parent>
Run Code Online (Sandbox Code Playgroud)

第二个(例如项目2)如下:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.0.BUILD-SNAPSHOT</version>
    <relativePath/> 
</parent>
Run Code Online (Sandbox Code Playgroud)

两者都有:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

好吧,项目1运行正常。我可以在我的.M2 repo文件夹中看到Spring Plugin 2.0.0.BUILD-SNAPSHOT。

项目2引发以下错误:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call the method org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin; but it does not exist. Its class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:

    jar:file:/.../.m2/repository/org/springframework/plugin/spring-plugin-core/2.0.0.BUILD-SNAPSHOT/spring-plugin-core-2.0.0.BUILD-SNAPSHOT.jar!/org/springframework/plugin/core/PluginRegistry.class

It was loaded from the following location:

    file:/.../.m2/repository/org/springframework/plugin/spring-plugin-core/2.0.0.BUILD-SNAPSHOT/spring-plugin-core-2.0.0.BUILD-SNAPSHOT.jar


Action:

Correct the classpath of your application so that it contains a single, …
Run Code Online (Sandbox Code Playgroud)

maven spring-boot

4
推荐指数
2
解决办法
2486
查看次数

如何使用SpringBoot + JPA存储PostgreSQL jsonb?

我正在开发一种迁移软件,它将使用来自REST服务的未知数据.

我已经考虑过使用MongoDB,但我决定不使用它并使用PostgreSQL.

阅读本文之后,我尝试使用Spring JPA在我的SpringBoot应用程序中实现它,但我不知道jsonb在我的实体中进行映射.

试过这个,但什么都不懂!

我就是这样的地方:

@Repository
@Transactional
public interface DnitRepository extends JpaRepository<Dnit, Long> {

    @Query(value = "insert into dnit(id,data) VALUES (:id,:data)", nativeQuery = true)
    void insertdata( @Param("id")Integer id,@Param("data") String data );

}
Run Code Online (Sandbox Code Playgroud)

和......

@RestController
public class TestController {

    @Autowired
    DnitRepository dnitRepository;  

    @RequestMapping(value = "/dnit", method = RequestMethod.GET)
    public String testBig() {
        dnitRepository.insertdata(2, someJsonDataAsString );
    }

}
Run Code Online (Sandbox Code Playgroud)

和表:

CREATE TABLE public.dnit
(
    id integer NOT NULL,
    data jsonb,
    CONSTRAINT dnit_pkey PRIMARY KEY (id)
) …
Run Code Online (Sandbox Code Playgroud)

postgresql spring-data-jpa spring-boot jsonb

3
推荐指数
3
解决办法
1万
查看次数