小编maq*_*jav的帖子

在声纳中禁用规则

我想禁用Sonar的规则,因此它不会在网页中显示结果.在我的情况下,我想隐藏(或不捕获)有关尾随注释的结果.

在某处配置它是否可行?

谢谢.

configuration sonarqube

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

过滤资源maven-shade-plugin

我正在尝试过滤我的jar中包含的资源.我正在使用shade-maven-plugin,这个将所有依赖项的所有资源添加到我生成的jar中,我只想包含我的项目资源.

这是我的pom定义:

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>1.6</version>
            <executions>
                <execution>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <minimizeJar>true</minimizeJar>
                        <transformers>
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>es.app.applet.MyApplet</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

我尝试添加下一个过滤器以删除所有资源,然后添加另一个过滤器,仅添加我的artifactID资源,但它不起作用.

                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>resources/*.*</exclude>
                        </excludes>
                    </filter> <filter>
                        <artifact>my.groupId:my.artifactId</artifact>
                        <includes>
                            <include>resources/*.*</include>
                        </includes>
                    </filter>
Run Code Online (Sandbox Code Playgroud)

想法?

谢谢.

maven maven-shade-plugin

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

几秒钟后在Android上捕获事件

我想在Android中为我的应用程序添加一个按钮,并在按下按钮几秒钟后在此按钮(onclick)上捕获事件,因此在第一次触摸时它不会做出反应.这可以在Android上实现吗?

现在我有下一个代码,用于捕获主页按钮上的onclick(在ActionBar中).

public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        showSendLogAlert();
    }

    return super.onOptionsItemSelected(item);
}
Run Code Online (Sandbox Code Playgroud)

当用户点击此按钮时,它会通过电子邮件发送一个小报告,我不想意外地启动此事件,这就是为什么我希望用户按下几秒钟以确保他想要这样做操作.

解:

基于以下评论,我得到了这个有效的解决方案:

@Override
protected void onCreate(final Bundle savedInstanceState) {
    // stuff

    // Set the home button clickable
    getActionBar().setHomeButtonEnabled(true);

    // Define a long click listener instead of normal one
    View homeButton = findViewById(android.R.id.home);
    homeButton.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            showSendLogAlert();
            return false;
        }
    });

    // more stuff
}
Run Code Online (Sandbox Code Playgroud)

android android-4.0-ice-cream-sandwich

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

自定义Java包JAXB wsimport

我正在尝试从wsdl文件生成一个带有maven和jaxb的客户端,里面有两个模式,一些具有相同名称的元素来自不同的模式

当我尝试执行编译时,我收到下一个错误:

Two declarations cause a collision in the ObjectFactory class.
Run Code Online (Sandbox Code Playgroud)

WSDL模式:

<wsdl:types>
    <schema targetNamespace="http://ws.services" xmlns="http://www.w3.org/2001/XMLSchema">...</schema>
    <schema targetNamespace="http://ws.models" xmlns="http://www.w3.org/2001/XMLSchema">...</schema>
</wsdl:types>
Run Code Online (Sandbox Code Playgroud)

我尝试重命名产生错误的元素,但然后我的spring客户端收到正确的SOAP消息,但它没有正确填充响应对象(它的所有属性都为null).我想问题可能来自重命名响应类,所以这就是为什么我试图生成不同的包保留所有类的原始名称.

为了做到这一点,我编写了下一个绑定文件,但我不知道我做错了它不能正常工作.

bindings.xml文件:

<?xml version="1.0" encoding="UTF-8"?>  
<jaxb:bindings version="2.1"  
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"  
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"  
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"  
    xmlns:xs="http://www.w3.org/2001/XMLSchema" >  

<jaxb:bindings schemaLocation="mywsdl.wsdl#types?schema1"
    node="/xs:schema[@targetNamespace='http://ws.services']">  
        <jaxb:schemaBindings>  
            <jaxb:package name="package1" />  
        </jaxb:schemaBindings>  
</jaxb:bindings>  

<jaxb:bindings schemaLocation="mywsdl.wsdl#types?schema2"
    node="/xs:schema[@targetNamespace='http://ws.models']">  
        <jaxb:schemaBindings>  
            <jaxb:package name="package2" />  
        </jaxb:schemaBindings>  
</jaxb:bindings> 

</jaxb:bindings>  
Run Code Online (Sandbox Code Playgroud)

maven文件中的配置部分是下一个,以防它有用:

<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
    <execution>
        <goals>
            <goal>wsimport</goal>
        </goals>
    </execution>
</executions>
<configuration>
    <wsdlLocation>wsdl/mywsdl.wsdl</wsdlLocation>
    <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
    <wsdlFiles>
        <wsdlFile>mywsdl.wsdl</wsdlFile>
    </wsdlFiles>
    <bindingDirectory>src/main/resources/wsdl</bindingDirectory>
    <bindingFiles>
        <bindingFile>bindings.xml</bindingFile>
    </bindingFiles>
    <packageName>original.package</packageName>
    <sourceDestDir>${basedir}/src/main/java</sourceDestDir>
</configuration> …
Run Code Online (Sandbox Code Playgroud)

java wsdl spring-ws jaxb maven

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

在Hibernate中使用Transformers.aliasToBean填充子bean

我有下几个豆子:

Address {
    String name;
    String number;
    String zipcode;
    String town;
}

MyEntity {
    Address address;
    String value1;
    String value2;
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试执行下一个Hibernate查询:

private final List<String> propertiesDistinct = Arrays.asList("address.name");
private final List<String> properties = Arrays.asList("address.number",
        "address.zipcode", "address.town")

ProjectionList projectionList = Projections.projectionList();

if (propertiesDistinct != null) {
    ProjectionList projectionListDistinct = Projections.projectionList();
for (String propertyDistinct : propertiesDistinct)
         projectionListDistinct.add(Projections.property(propertyDistinct).as(propertyDistinct));

    projectionList.add(Projections.distinct(projectionListAgrupar));
}

if (properties != null)
    for (String property : properties)
         projectionList.add(Projections.property(property).as(property));
criterio.setProjection(projectionList);

// MORE FILTERS ON MyEntity FIELDS
//... criterio.add(Restrinctions...);

// I want to …
Run Code Online (Sandbox Code Playgroud)

java hibernate

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

Spring中避免事务回滚

假设我有下一个代码:

@Autowired
private IManager1 manager1;

@Autowired
private IManager2 manager2;

@Autowired
private IManager3 manager3;

@Transactional
public void run() {
     manager1.doStuff();
     manager2.registerStuffDone();

     manager3.doStuff();
     manager2.registerStuffDone();

     manager1.doMoreStuff();
     manager2.registerStuffDone();
}
Run Code Online (Sandbox Code Playgroud)

如果启动任何异常,我想回滚“doStuff()”方法完成的所有操作,但我不想回滚“registerStuffDone()”方法记录的数据。

我一直在阅读 @Transactional 注释的传播选项,但我不明白如何正确使用它们。

每个经理在内部都使用 hiberante 来提交更改:

@Autowired
private IManager1Dao manager1Dao;

@Transactional
public void doStuff() {
    manager1Dao.doStuff();
}
Run Code Online (Sandbox Code Playgroud)

dao 看起来像这样:

@PersistenceContext
protected EntityManager entityManager;

public void doStuff() {
    MyObject whatever = doThings();
    entityManager.merge(whatever);
}
Run Code Online (Sandbox Code Playgroud)

这是我的 applicationContext 配置:

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSourcePool" />
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
    </property>
</bean>

<bean id="entityManager" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
    <property name="entityManagerFactory" …
Run Code Online (Sandbox Code Playgroud)

java spring jpa jdbc

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

表中的Lua拉丁字符

我是Lua的新手并且正在寻找互联网我找不到解决问题的方法,或者如果我真的可以做下一件事就给出答案.

我有下一张桌子.如你所见,钥匙有一个í:

DB = {
    ["Vigía"] = 112
}
Run Code Online (Sandbox Code Playgroud)

如果我尝试从表中检索该值,则返回nil.我尝试删除í字符然后我可以得到值112.

我可以在这种情况下使用拉丁字符作为键吗?

谢谢!

lua lua-table

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