相关疑难解决方法(0)

Maven spring boot使用参数运行调试

通常我用命令运行我的Spring Boot应用程序:

mvn spring-boot:run -Drun.arguments=--server.port=9090 \
   -Dpath.to.config.dir=/var/data/my/config/dir
Run Code Online (Sandbox Code Playgroud)

我想设置自定义端口进行调试,所以我可以从eclipse连接.当我从示例http://docs.spring.io/spring-boot/docs/1.1.2.BUILD-SNAPSHOT/maven-plugin/examples/run-debug.html添加参数时

mvn spring-boot:run -Drun.arguments=--server.port=9090 \
   -Dpath.to.config.dir=/var/data/my/config/dir \
   -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8787"
Run Code Online (Sandbox Code Playgroud)

它有效,但其他论点喜欢server.portpath.to.config.dir不再被认可,我得到例外:

org.springframework.beans.factory.BeanDefinitionStoreException: Failed
to parse configuration class [com.my.app.Controller]; nested exception
is java.lang.IllegalArgumentException: Could not resolve placeholder
'path.to.config.dir' in string value
file:///${path.to.config.dir}/some.properties"
Run Code Online (Sandbox Code Playgroud)

问题:如何运行所有参数?

java spring maven-3 maven spring-boot

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

在Heroku上运行使用gradle构建的Spring应用程序

我使用Gradle构建的Spring应用程序有问题.应用程序包括MongoDB(来自Heroku的MongoHQ).

我管理了如何在heroku上推送所有内容,我已将此代码添加到我的项目中:

@Configuration
public class MongoHQConfiguration {

    public @Bean MongoDbFactory mongoDbFactory() throws MongoException, UnknownHostException {
        return new SimpleMongoDbFactory(new MongoURI(System.getenv("MONGOHQ_URL")));
    }

    public @Bean MongoTemplate mongoTemplate() throws Exception {
        return new MongoTemplate(mongoDbFactory());
    }
}
Run Code Online (Sandbox Code Playgroud)

在使用gradle将buildpack更改为one之后,我使用MongoHQ Sandbox在Heroku免费帐户上推送了所有内容.

但在尝试通过Web浏览器运行我的应用程序后,我收到此错误:

应用程序中发生错误,无法提供您的页面.请稍后重试.

如果您是应用程序所有者,请检查日志以获取详细信息.

heroku logs 给我这个输出:

2014-10-15T18:19:30.293964 + 00:00 heroku [web.1]:用命令启动进程 java -Xmx384m -Xss512k -XX:+UseCompressedOops -jar build/libs/*.jar

2014-10-15T18:19:30.797673 + 00:00 app [web.1]:错误:无法访问jarfile build/libs/*.jar

2014-10-15T18:19:31.474525 + 00:00 heroku [web.1]:状态从开始变为崩溃

2014-10-15T18:19:31.464753 + 00:00 heroku [web.1]:进程退出状态1

2014-10-15T18:19:32.577398 + 00:00 heroku [router]:at = error code = H10 desc ="App crashed"method …

java deployment spring heroku gradle

14
推荐指数
2
解决办法
5573
查看次数

使用两个端口配置Spring Boot

我正在尝试使用两个不同的端口在Spring Boot中配置应用程序,但我还没有.我的第一个aproximation是两个控制器,我在两个控制器中用container.setPort(8080)定义了一个@Bean; 我的第二个aproximation已经添加了执行器依赖并改变了管理的端口,但我的应用程序没有运行."地址已在使用中:绑定",如何使用两个端口来配置应用程序?我想要一个端口用于管理员,另一个端口用于我的api的咨询.

spring spring-boot spring-boot-actuator

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

如何使用spring boot更改embebed-tomcat默认端口?

我正在使用带有maven的spring-boot,这是我的配置类:

package hello;

import javax.servlet.MultipartConfigElement;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

应用程序启动时在控制台中显示此行:

2014-11-06 17:00:55.102  INFO 4669 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080/http
Run Code Online (Sandbox Code Playgroud)

我想将TomcatEmbedded端口更改为8081.感谢:D

java tomcat spring-boot

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

Spring Boot + Tomcat忽略server.port属性?

我目前正试图通过一些小的配置更改来启动和运行Spring Boot应用程序,但我似乎无法让端口正确监听.似乎tomcat实例加载的server.xml会覆盖我的application.properties文件指定的任何内容.

application.properties:

logging.level.app = TRACE
logging.file = /tmp/my-server.log
server.port = 8081
Run Code Online (Sandbox Code Playgroud)

当我将其部署到我的/ usr/local/tomcat/webapps时,我可以访问服务器,但只能访问端口8080.它似乎忽略了server.port属性.我相信服务器正在正确地获取属性文件,因为日志记录正确地转到/tmp/my-server.log

最终目标是让服务器在Amazon Elastic Beanstalk中运行时监听我选择的端口.我可以更新负载均衡器上的端口,但是如果服务器只监听它的预配置端口,那也没关系.

提前感谢您的帮助!

OSX Yosemite,Tomcat 8.0.24,Spring Boot v1.2.4

java spring tomcat gradle spring-boot

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

spring-boot 上的集成测试抛出连接被拒绝

我对 Spring Boot 进行了单元测试:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)
public class CustomerControllerIT {
    private RestTemplate restTemplate = new RestTemplate();
    @Test
    public void findAllCustomers() throws Exception {
        ResponseEntity<List<Customer>> responseEntity = restTemplate.exchange(
                "http://localhost:8080/Customer", HttpMethod.GET, null,
                new ParameterizedTypeReference<List<Customer>>() {
                });
        List<Customer> list = responseEntity.getBody();
        Assert.assertEquals(list.size(), 0);
    }
}
Run Code Online (Sandbox Code Playgroud)
  • 如果我在启动的应用程序上启动测试 - 测试正常

  • 如果我尝试仅启动 IT,则会出现连接被拒绝的错误

application.properties的单启动是一样的。

用于测试并位于资源和测试资源中。

Application.class 是:

@ComponentScan({"mypackage"})
@EntityScan(basePackages = {"mypackage.model"})
@EnableJpaRepositories(basePackages = {"mypackage.persistence"})
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

integration-testing spring-boot

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

如何在docker中公开${PORT} spring boot应用程序随机端口?

如何${PORT}在 中公开 Spring Boot 应用程序docker

Spring Boot 应用程序在随机端口上启动,我必须在 docker 中公开相同的端口。

是否可以?

port docker spring-boot

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

在Spring启动程序中更改端口号.没有application.properties

我刚从spring.io https://spring.io/guides/gs/rest-service/导入了一个java项目

我在日食中做到了.我想更改嵌入式tomcat运行的端口号,但我看不到任何application.properties(没有src/main/resources),就像我以前通过File手动创建一个spring boot应用程序一样>新建 - > ...

这就是结构的样子

在此输入图像描述

我检查了manifest.yml甚至打字

服务器:端口:9090

但它说,'Cloudfoundary Manifest'类型的未知属性'服务器'

eclipse spring-boot

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

如何使用maven更改tomcat服务器的端口号

我正在使用spring mvc框架和maven编写Rest服务.我现在正在使用tomcat服务器.我的项目是pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0     http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.springframework</groupId>
<artifactId>gs-rest-service</artifactId>
<version>0.1.0</version>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.5.RELEASE</version>
</parent>

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

    </dependency>
</dependencies>

<properties>
    <java.version>1.8</java.version>
</properties>


<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

    </plugins>

</build>

<repositories>
    <repository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </pluginRepository>
</pluginRepositories>
</project>
Run Code Online (Sandbox Code Playgroud)

该项目使用tomcat服务器并默认在端口8080上运行.任何人都可以帮助我理解它从哪里获取此配置以及如何更改运行tomcat的端口.

我的初步分析告诉我在spring.boot插件中完成了一些配置,我需要在我的pom中覆盖它.任何人都可以帮助我覆盖tomcat默认端口并在其他端口上运行它.

java tomcat maven spring-boot

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

如何使用Gradle更改Spring Boot应用程序的端口?

一个简单的问题是:如何使用gradle更改Spring Boot应用程序端口?


如果您不使用gradle,这里已经列出了许多正确答案。因此,如果没有任何问题,请参阅此帖子。

port gradle spring-boot

2
推荐指数
3
解决办法
2121
查看次数