小编Mor*_*fic的帖子

Vaadin:如何在战争中加入META-INF /服务?

我有一个Vaadin 7 maven web项目,它有一些注释可以创建服务定义META-INF/services.

我将其添加到pom中以便处理注释:

<!-- Run annotation processors on src/main/java sources -->
<plugin>
    <groupId>org.bsc.maven</groupId>
    <artifactId>maven-processor-plugin</artifactId>
    <version>3.3.1</version>
    <executions>
        <execution>
            <id>process</id>
            <goals>
                <goal>process</goal>
            </goals>
            <phase>generate-sources</phase>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

文件显示在内,target/classes/META-INF/services但没有进入最后的战争.

我尝试将文件夹添加到maven-war-plugin,如下所示:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>3.0.0</version>
    <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <packagingIncludes>target/classes/*</packagingIncludes>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

但是大部分的Vaadin文件并没有进入战争,也没有用.任何的想法?

java war maven-3 maven vaadin7

7
推荐指数
1
解决办法
1318
查看次数

Rabbitmq camel spring boot auto config

我有骆驼和rabbitmq配置如下,它正在工作.我希望改进配置设置.

的pom.xml

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-rabbitmq-starter</artifactId>
    <version>2.19.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

application.yml

spring: 
  rabbitmq:
    host: rabbithost-url
    port: 5672
    username: my-user
    password: my-password
Run Code Online (Sandbox Code Playgroud)

配置bean

@Configuration
public class CamelConfig {

    @Resource private Environment env;

    @Bean
    public ConnectionFactory rabbitConnectionFactory(){
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost(env.getProperty("spring.rabbitmq.host"));
        connectionFactory.setPort(Integer.valueOf(env.getProperty("spring.rabbitmq.port")));
        connectionFactory.setAutomaticRecoveryEnabled(true);
        // more config options here etc
        return connectionFactory;
    }
}
Run Code Online (Sandbox Code Playgroud)

路线示例

@Component
public class MyRoute extends RouteBuilder {

    @Override
    public void configure() throws Exception {

     from("direct:startQueuePoint")
          .id("idOfQueueHere")
          .to("rabbitmq://rabbithost-url:5672/TEST-QUEUE.exchange?queue=TEST-QUEUE.queue&autoDelete=false&connectionFactory=#rabbitConnectionFactory")
          .end();
    }
}
Run Code Online (Sandbox Code Playgroud)

想改善以下几点?或者至少看看它是否可能?

1) 如何利用spring boot autowiring.我想通过添加自定义CamelConfig> rabbitConnectionFactory来复制bean吗?它没有使用RabbitAutoconfiguration?

2) 当我使用连接工厂时,我引用了rabbitmq-url和端口两次?我将它添加到rabbitConnectionFactory bean对象和camel …

configuration apache-camel autowired spring-boot spring-rabbitmq

6
推荐指数
1
解决办法
1910
查看次数

如何获得最长的“重叠”单词

前提:假设您有一个包含单词的表,其中有些单词可能不同,有些“可能重叠”,这意味着较长的单词以较短的单词开头,例如:

---------------
|    word     |
---------------
| dog         | *
| games       | *
| stat        |
| state       | 
| statement   | *
| fulfill     |
| fulfilled   | *
| fulfillment | *
---------------
Run Code Online (Sandbox Code Playgroud)

问题:在这种情况下,如何编写一个返回非重叠+最长重叠单词列表的查询?

在上面的示例中,所需的单词由 a 标识*,根据以下扩展说明:

  • dog并且games不与任何内容重叠,因此它们是“独奏/独特”类别中最长的
  • statementstate与and重叠stat并且是最长的
  • fulfilled与 重叠fulfill并且更长(不与 重叠fulfillment
  • fulfillment与 重叠fulfill并且更长(不与 重叠fulfilled

:请注意,为了简单起见,数据样本有所减少。实际上,有几百万条记录需要查询,并且事先没有已知的搜索词,因此不可能直接使用诸如WHERE word LIKE …

sql oracle

5
推荐指数
2
解决办法
276
查看次数

在hibernate中找不到数据源

我现在尝试从退出时解决这个问题,我正在使用OSUSER api进行简单的用户和组访问.它适用于JDBC提供程序(在OsUser.xml和PropertySet.xml中)

现在,当我尝试使用它时,com.opensymphony.user.provider.hibernate.HibernateCredentialsProvider它显示我错误:

  at net.sf.hibernate.HibernateException: Could not find datasource: Name jdbc2 is not bound in this Context
  at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:47)
  at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:75)
  at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:144)
  at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:571)
  at com.opensymphony.user.provider.hibernate.dao.SessionManager.<init>(SessionManager.java:34)
  at com.opensymphony.user.provider.hibernate.impl.OSUserHibernateConfigurationProviderImpl.setupConfiguration(OSUserHibernateConfigurationProviderImpl.java:101)
  at com.opensymphony.user.provider.hibernate.HibernateBaseProvider.init(HibernateBaseProvider.java:83)
  at com.opensymphony.user.provider.hibernate.HibernateProfileProvider.init(HibernateProfileProvider.java:98)
  at com.opensymphony.user.util.ConfigLoader.addProvider(ConfigLoader.java:113)
  at com.opensymphony.user.util.ConfigLoader.access$100(ConfigLoader.java:39)
  at com.opensymphony.user.util.ConfigLoader$ConfigHandler.endElement(ConfigLoader.java:144)
  at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:606)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1742)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2900)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
  at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
  at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
  at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
  at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
  at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
  at com.opensymphony.user.util.ConfigLoader.load(ConfigLoader.java:61)
  at com.opensymphony.user.UserManager.<init>(UserManager.java:108)
  at com.opensymphony.user.UserManager.<init>(UserManager.java:60)
  at com.opensymphony.user.UserManager.getInstance(UserManager.java:127)
  at com.fhl.LoginPage$1.onSubmit(LoginPage.java:28)
  at org.apache.wicket.markup.html.form.Form$10.component(Form.java:1157)
  at org.apache.wicket.markup.html.form.Form$10.component(Form.java:1152)
  at …
Run Code Online (Sandbox Code Playgroud)

java tomcat wicket hibernate jndi

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

为什么@Qualifier不起作用

我使用spring boot + jdbctemplate,我必须使用多数据源,例如

@Configuration
public class MultiDBConfig {

    @Bean(name = "fooDb")
    @ConfigurationProperties(prefix = "foo.datasource")
    public DataSource fooDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "fooJdbcTemplate")
    public JdbcTemplate fooJdbcTemplate(@Qualifier("fooDb") DataSource ds) {
        return new JdbcTemplate(ds);
    }

    @Bean(name = "barDb")
    @ConfigurationProperties(prefix = "bar.datasource")
    public DataSource barDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "barJdbcTemplate")
    public JdbcTemplate barJdbcTemplate(@Qualifier("barDb") DataSource ds) {
        return new JdbcTemplate(ds);
    }

}
Run Code Online (Sandbox Code Playgroud)

当我启动我的应用程序时,它失败并具有以下错误信息

Parameter 0 of method fooJdbcTemplate in com.example.multidatasourcedemo.MultiDBConfig required a single bean, but 3 were found:
    - fooDb: …
Run Code Online (Sandbox Code Playgroud)

spring-boot

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

使用vaadin的Spring Boot时的404 for js文件

在带有spring-boot的vaadin项目中使用spring security时遇到问题。因此,我正在使用PdfViewer插件来显示PDF文件。但是我收到以下错误消息:

error:"Not Found"
message:"No message available"
path:"/APP/PUBLISHED/pdf.worker.js"
status:404
Run Code Online (Sandbox Code Playgroud)

我的春季安全配置如下所示:

@Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .headers()
                .defaultsDisabled()
                .frameOptions().sameOrigin().and()
                .csrf().disable() // Use Vaadin's CSRF protection
                .authorizeRequests().antMatchers("/").permitAll()
                .antMatchers("/vaadinServlet/HEARTBEAT/**").permitAll()
                .antMatchers("/vaadinServlet/UIDL/**").permitAll()
                .antMatchers("/vaadinServlet/APP/PUBLISHED/**").permitAll()
                .antMatchers("login?debug").permitAll()
                .antMatchers("/#!pwdreset/*").permitAll()
                .antMatchers("/pwdreset/*").permitAll()
                .and()
                .authorizeRequests()
                .and()
                .formLogin().loginPage("/#!login").permitAll()
                .and()
                .logout().logoutUrl("/#!login?logout").logoutSuccessUrl("/").permitAll().and()
                .sessionManagement().sessionFixation().newSession();

    }

@Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/resources/**", "/VAADIN/**");
    }
Run Code Online (Sandbox Code Playgroud)

因此,在Chrome浏览器中检查了已加载的文件,我看到了/ vaadinServlet / APP / PUBLISHED /文件夹,其中包含所有需要的文件。

在不使用Spring Security的情况下使用Addon可以正常工作,所以有人有想法吗?


更新资料

它似乎与Spring安全性无关,因为我在一个新的简单项目中测试Addon时得到了类似的行为。弹簧靴似乎是个问题。

要重现此问题,您需要(要下载的完整项目):

  • 基本的春季启动+ vaadin应用程序框架
  • 简单的PDF及以下 /webapp/files
  • 在pom和widgetset中编译的PdfViewer加载项
  • 下面的简单UI
error:"Not Found"
message:"No …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security vaadin spring-boot

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

Mockito拒绝将TypeSafeMatcher与通用方法API配对

我想测试调用某些API的代码:

public <T extends MessageLite> ApiFuture<String> publish(final T message) throws Exception {
}


public <T extends MessageLite> ApiFuture<String> publish(final T message, final ApiFutureCallback<T> futureCallback) throws Exception {
}


public <T> String publishSynchronous(final String message, final ApiFutureCallback<T> futureCallback) throws Exception {
}
Run Code Online (Sandbox Code Playgroud)

在我的测试中,我使用了嘲笑模拟,然后我想验证它是否被具有字段的原型对象(扩展了MessageLite)调用 isSuccess = false

我已经厌倦了这段代码:

    verify(customPublisher, times(0)).publish(isFailureResult(), anyObject());
Run Code Online (Sandbox Code Playgroud)

和这个匹配器:

public class FailResultMatcher extends TypeSafeMatcher<MessageLite> {

    @Override
    protected boolean matchesSafely(final MessageLite sentResult) {
        return !((SdkResult)sentResult).getIsSuccess();
    }


    public static FailResultMatcher isFailureResult() {
        return new FailResultMatcher();
    }

    @Override
    public void describeTo(final Description …
Run Code Online (Sandbox Code Playgroud)

java unit-testing mocking mockito java-8

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