小编Yas*_*aka的帖子

Spring Boot删除Whitelabel错误页面

我正在尝试删除白标错误页面,所以我所做的是为"/ error"创建了一个控制器映射,

@RestController
public class IndexController {

    @RequestMapping(value = "/error")
    public String error() {
        return "Error handling";
    }

}
Run Code Online (Sandbox Code Playgroud)

但现在我收到了这个错误.

Exception in thread "AWT-EventQueue-0" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource   [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Invocation  of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'basicErrorController' bean method 
public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>>  org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletR equest)
to {[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'indexController' bean method
Run Code Online (Sandbox Code Playgroud)

不知道我做错了什么.请指教.

编辑:

已经添加 error.whitelabel.enabled=false 到application.properties文件中,仍然会收到相同的错误

spring spring-boot

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

使用Maven Shade插件的Spring启动 - 未映射控制器(404错误)

对于我的带有嵌入式tomcat的Spring启动应用程序,由于某些限制,我需要废除 spring-boot-maven-plugin并需要使用maven-shade-plugin.使用maven package命令,我可以成功创建jar文件.但是,我的所有控制器都停止工作,并给我404错误.此外,我的资源文件夹中的静态内容不再提供.总是得到404错误.

我的pom.xml

<dependencyManagement>
    <dependencies>
        <dependency>
            <!-- Import dependency management from Spring Boot -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>1.2.7.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.7</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies> 

<build>
    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>


        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>

            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <filters>
                            <filter>
                                <artifact>*:*</artifact>
                                <excludes>
                                    <exclude>META-INF/*.SF</exclude>
                                    <exclude>META-INF/*.DSA</exclude>
                                    <exclude>META-INF/*.RSA</exclude>
                                </excludes>
                            </filter>
                        </filters>

                        <transformers>
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>abc.MyMainClass</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution> …
Run Code Online (Sandbox Code Playgroud)

maven-shade-plugin spring-boot spring-boot-maven-plugin

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

没有依赖项的 Spring Boot 可执行 Jar 文件

在没有依赖项的情况下构建 spring boot jar 文件的最简单方法是什么?基本上我应该能够将依赖项 jar 文件保存在单独的文件夹中。

目前我正在使用 spring boot maven 插件,但是,它会创建一个包含所有依赖项的 Fat jar 文件。

spring-boot spring-boot-maven-plugin

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

Android大规模项目 - 可以分成几个图书馆项目吗?

我将开发一个非常大规模的android项目,它有数千个类和资源.我计划将应用程序分离到模块中,并将它们作为库项目单独开发.后来将它们组合在一起 (应用程序可能包含5-6个模块,因此计划创建5-6个库项目并将它们组合在一起)

这种方法可以吗?或Android专家,请建议一种维护和开发这样一个大项目的方法?


编辑:

库为多个应用程序保存共享代码 - >是同意100%为真

但这个项目就像几个项目的组合.就像这样:

主屏幕仪表板有8个按钮,代表你点击一个按钮的8个模块 - >它打开一个活动,它有自己的数千个片段,布局,绘图等,独立于其他模块

所以同样我有非相互依赖的用例,可以很容易地分开,4-5个开发人员将参与这个项目,所以如果我可以分成几个库项目,我可以简单地根据模块分配开发人员(库项目) )

因此,一种方法是创建一个项目并通过com.name.something.Module1模块创建包结构

在这个包下我有

com.name.something.Module1.activity
com.name.something.Module1.util
com.name.something.Module1.widget
com.name.something.Module1.data
com.name.something.Module1.dao
Run Code Online (Sandbox Code Playgroud)

和模块2

com.name.something.Module2

com.name.something.Module2.activity
com.name.something.Module2.util
com.name.something.Module2.widget
Run Code Online (Sandbox Code Playgroud)

等等

所以这是第一种方法,但每个模块都有数千个类和资源,布局xml文件等.

另一种方法是将模块分离为库项目.我不知道大型项目如何维护他们的代码库,如facebook,twitter等.

请指教.

android android-library

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

Spring Android REST模板使用内容类型text/html解析JSON数据

我正在使用android spring REST模板从外部API中提取一些数据.那些API返回JSON字符串但响应内容类型是"text/html",如果内容类型是"application/json",我可以轻松地解析数据而没有任何问题,因为这些API是第三方API我无法更改内容类型的回应.

我正在使用"MappingJacksonHttpMessageConverter"类作为消息转换器.

当我尝试解析数据时,我遇到了异常.

org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type .... and content type [text/html;charset=utf-8]
Run Code Online (Sandbox Code Playgroud)

是否有任何配置,参数或我可以解析这些JSON数据的东西?

android jackson spring-android

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